This commit is contained in:
laodaming 2023-09-05 14:11:21 +08:00
parent f6e70d0386
commit 7cd48778e5

View File

@ -117,7 +117,7 @@ type wsConnectItem struct {
// 请求建立连接升级websocket协议 // 请求建立连接升级websocket协议
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
origin := r.Header.Get("Origin") origin := r.Header.Get("Origin")
//判断是不是允许的host //判断是不是允许的跨域
upgrader.CheckOrigin = func(r *http.Request) bool { upgrader.CheckOrigin = func(r *http.Request) bool {
if _, ok := mapAllowOrigin[origin]; !ok { if _, ok := mapAllowOrigin[origin]; !ok {
return false return false