跨域事件源

Mar*_*van 15 cross-domain node.js cors

我正在尝试使用nodejs创建一个EventSource服务器,这将服务器跨域请求.我发送回Access-Control-Allow-Origin标题,但浏览器(也不是Chrome或Opera)不允许我连接.有我发回的标题:

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'
});
Run Code Online (Sandbox Code Playgroud)

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

问候

4es*_*n0k 3

参见https://github.com/Yaffle/EventSource - 可以采用polyfill来支持Firefox、Webkit和IE 8+的CORS