gpt4 book ai didi

node.js - 跨域事件源

转载 作者:IT老高 更新时间:2023-10-28 23:03:22 28 4
gpt4 key购买 nike

我正在尝试使用 nodejs 创建一个 EventSource 服务器,它将跨域服务器请求。我正在发回 Access-Control-Allow-Origin header ,但浏览器(也不是 Chrome 或 Opera)不会让我连接。有我发回的 header :

this._response.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true'
});

我怎样才能以正确的方式做到这一点?

问候

最佳答案

Allow-Credentials 不能与 Allow-Origin 设置为 * 一起使用。考虑在您的响应中写入收到的 Origin-header。

关于node.js - 跨域事件源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6315095/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com