socket.io-client how to set request header when making connection

后端 未结 5 1419
春和景丽
春和景丽 2020-12-24 05:16

I\'m trying to set a http header when socket.io client makes the connection request. Is there a way to do this?

Here is what i\'m doing:

// server si         


        
5条回答
  •  温柔的废话
    2020-12-24 06:18

    It seems like the client doesn't support setting headers, as not all transports allow for the setting of headers.

    This post by facundoolano details a workaround to authentication that doesn't require placing the auth token in the query string.

    His workaround module can be found at https://github.com/invisiblejs/socketio-auth.

    Makes me wonder why on server-side, socket.io allows for the request headers to be accessed...

提交回复
热议问题