我正在使用btford.socket-io,并尝试与节点通话。
工作正常,但是在我从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:"*"})
,但没有运气。
答案 0 :(得分:1)
关于这个A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true.
将允许来源设置为固定域将解决此问题,目前,如果我不弄错,http://example.org:5000
。我相信你应该包括端口号。
我不清楚理解为什么你有头文件凭证。