如何在Javascript中为websocket设置请求标头中的cookie?

时间:2017-03-19 17:15:54

标签: javascript angular cookies websocket

我正在使用Angular2,我的后端使用请求标头中的Cookie验证websocket请求。 我创建了一个cookie,但它没有出现在websocket请求的标题中。

这是我需要拥有的一个例子。

enter image description here

现在我在设置时没有看到cookie。

enter image description here

我使用此示例创建angular2服务:https://tutorialedge.net/angular-2-websockets-tutorial

谢谢!

1 个答案:

答案 0 :(得分:0)

这些请求是针对两个不同的主机http://localhost:3000teamcall.the-patriots.com,因此第一个的Cookie不会发送到第二个。