diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 52f3034d..553f4123 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -84,7 +84,10 @@ type wsConnectItem struct { func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //把子协议携带的token设置到标准token头信息中 token := r.Header.Get("Sec-Websocket-Protocol") - r.Header.Set("Authorization", "Bearer "+token) + //有token是正常用户,无则是白板用户,也可以连接 + if token != "" { + r.Header.Set("Authorization", "Bearer "+token) + } //设置Sec-Websocket-Protocol upgrader.Subprotocols = []string{token} //升级websocket