【发布时间】:2017-05-22 17:33:51
【问题描述】:
我正在开发一个 API(使用 Node.js)并将 Socket.io 与 Express 一起使用,我遇到了一些关于 CORS 的错误,我在 localhost 中使用 Express 和 Socket.io 2.0 解决了这个问题,这与 *.azurewebsites 一起使用。净,但不再有效。
Express 测试(见控制台):http://crawlerbackend.azurewebsites.net/test_cors_express_azure.html
Socket.io 测试(见控制台):http://crawlerbackend.azurewebsites.net/test_cors_socketio_azure.html
但我需要向所有人公开我的 Socket.io API,因为我的客户需要它,并在 Heroku 中测试了相同的文件:
Express 测试(见控制台):https://testcrawlersite.herokuapp.com/test_cors_express_azure.html
Socket.io 测试(见控制台):https://testcrawlersite.herokuapp.com/test_cors_socketio_azure.html
我根据他们的文档遵循最佳 Express 和 Socket.io 实践。我有一个独特的结论,我需要在 IISNode 中进行配置吗?还是在门户中?与“CORS”选项不同(使用 * 设置)。
这是错误:
XMLHttpRequest cannot load https://crawlerbackend.azurewebsites.net/socket.io/?EIO=3&transport=polling&t=LmW1TfL. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://testcrawlersite.herokuapp.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
【问题讨论】:
标签: node.js azure websocket azure-web-app-service