Go socket io show this error failed: Error during WebSocket handshake: Unexpected response code: 403

So im trying to use socket io with go and angular but i have that error
Error
image

Go Code

   gin.SetMode(gin.ReleaseMode)
    router := gin.Default()
   //CORS
   router.Use(cors.New(cors.Config{
   AllowOrigins:     []string{"http://localhost:4200"},
   AllowMethods:     []string{"PUT", "PATCH", "POST", "GET", "DELETE"},
    AllowHeaders:     []string{"Origin", "X-Requested-With", "Content-Type", "Cache- 
 Control", "Pragma", "Authorization", "Accept", "Accept-Encoding"},

    ExposeHeaders:    []string{"Content-Length"},

    AllowCredentials: true,

    // AllowOriginFunc: func(origin string) bool {

    //  return origin == "*"

    // },

    MaxAge: 12 * time.Hour,

}))
server, err := socketio.NewServer(nil)
if err != nil {

    log.Fatal(err)

}

server.OnConnect("/", func(s socketio.Conn) error {

    s.SetContext("")

    fmt.Println("connected:", s.ID())

    return nil

})

server.OnEvent("/", "message", func(s socketio.Conn, msg string) {

    fmt.Println("notice:", msg)

    s.Emit("response", "Nuevo Pedido")

})

server.OnEvent("/chat", "msg", func(s socketio.Conn, msg string) string {

    s.SetContext(msg)

    return "recv " + msg

})

server.OnEvent("/", "bye", func(s socketio.Conn) string {

    last := s.Context().(string)

    s.Emit("bye", last)

    s.Close()

    return last

})

server.OnDisconnect("/", func(s socketio.Conn, msg string) {

    fmt.Println("closed", msg)

})

router.GET("/socket.io/*any", gin.WrapH(server))

router.POST("/socket.io/*any", gin.WrapH(server))

// router.Handle("WSS", "/socket.io", []gin.HandlerFunc{SocketHandler})

//SERVER PORT

router.Run(":5000")

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.