HTTP Authorization Header in EventSource (Server Sent Events)

前端 未结 8 1989
梦谈多话
梦谈多话 2021-02-01 01:52

I need to set an Authorization header to an HTML5 EventSource. As Server Sent Events seems to be disused since Websockets appeared, I cannot find any useful documentation. The a

8条回答
  •  生来不讨喜
    2021-02-01 02:31

    EventSource doesn't have an API for sending HTTP headers to server. I was struggling with this problem too when I was building realtime-chat using SSE.

    However I think cookies will be sent automatically if your SSE server is the same server as your authentication server.

提交回复
热议问题