javascript - 如何在Javascript中的websocket请求 header 中设置cookie?

标签 javascript angular cookies websocket

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

这是我需要的一个示例。

enter image description here

目前,我在设置 cookie 时看不到它。

enter image description here

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

谢谢!

最佳答案

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

关于javascript - 如何在Javascript中的websocket请求 header 中设置cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42889584/

相关文章:

javascript - 使用虚拟键盘时物理键盘不会禁用

javascript - 单击时将选项移动到下一个选择

html - Angular2 从一个组件导航到同级组件而不拆除第一个组件

Angular2 typescript - kendo ui 网格列模板(单击)不起作用

javascript - JS 获取 cookie ASP.NET Core Identity

xcode - El Capitan 中的 stringWithContentsOfURL cookie jar

javascript - RESTful API 调用未更新本地数组?

angular - 未捕获的类型错误 : Cannot read property 'teams' of undefined thrown - Karma

php - Cookies 不工作,apache 到 nginx

javascript - Titanium,从另一个JS文件调用一个JS文件中的函数