Custom headers for WebSocket JS

前端 未结 2 2139
遥遥无期
遥遥无期 2021-02-19 06:40

I finding a simple solution to use WebSocket with custom headers for web app based on PHP as backend and js+vuejs as frontend.

My app should connect to WebSocket server

2条回答
  •  情话喂你
    2021-02-19 07:06

    I'm so confused at the massive amount of mis-information of websockets and headers. There is a way to add headers to WebSocket connections.

    Like this

    options.headers= {"header1":"value"}
    const socket = new WebSocket('wss://yourwebsocketAPIpath', [],options )
    

提交回复
热议问题