diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 6c724f6a..b5929a92 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -81,9 +81,10 @@ type wsConnectItem struct { // 请求建立连接,升级websocket协议 func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //把子协议携带的token设置到标准token头信息中 - r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol")) + token := r.Header.Get("Sec-Websocket-Protocol") + r.Header.Set("Authorization", "Bearer "+token) //设置Sec-Websocket-Protocol - upgrade.Subprotocols = []string{r.Header.Get("Sec-Websocket-Protocol")} + upgrade.Subprotocols = []string{token} //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil {