【发布时间】:2016-09-03 03:23:05
【问题描述】:
我正在使用 btford.socket-io,并尝试与 node 对话。
一切正常,但在我从 localhost:5000 更改为 example.org 之后就不行了,如下所示:
.factory('socket',function(socketFactory){
//working
var myIoSocket = io.connect('http://localhost:5000');
//not working
var myIoSocket = io.connect('http://example.org:5000');
mySocket = socketFactory({
ioSocket: myIoSocket
});
return mySocket;
})
我的控制台出现了这个错误
XMLHttpRequest cannot load http://example.com:5000/socket.io/?EIO=3&transport=polling&t=LIGH5VO. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
:8100/#/app/completed:1 XMLHttpRequest cannot load http://example.com:5000/socket.io/?EIO=3&transport=polling&t=LIGH7BS. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
我还尝试在我的快递中使用this npm 设置cors({origin:"*"}),但没有运气。
【问题讨论】:
标签: angularjs node.js sockets express cors