when i setup subscription endpoint(websocket connection) in my gqlgen + go code, it display an error as unable to upgrade *http.response to websocket websocket: request origin not allowed by Upgrader.CheckOrigin:
- Ngôn ngữ chính
- Go
- Star
- 10.8k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 36 phút
- Pull request đã merge (30 ngày)
- 26
Mô tả
when i try to start websocket connection from frontend code,it display an error as unable to upgrade *http.response to websocket websocket: request origin not allowed by Upgrader.CheckOrigin in the server side
to fix it i update the package but it still persist
- `go version`?
- // Create the GraphQL server
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{
Resolvers: resolver,
}))
srv.AddTransport(&transport.Websocket{
Upgrader: websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
// Replace "http://example.com" with the allowed origin
allowedOrigin := "http://localhost:5173/"
return r.Header.Get("Origin") == allowedOrigin
},
},
})
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.