sockjs-node: Error: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin'
Hi
I’m running node-server in windows in my local computer. With sockjs-client 1.0.0-beta.12 (I use browserify for bundle the frontend), when I try to connect chrome gives me this error:
XMLHttpRequest cannot load http://localhost:12540/websocket/info?t=1429552020306. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'null' is therefore not allowed access.
It’s my fault or is a error from the beta version?
client
Net.prototype.connect = function(url, port, prefix) { //url: 'localhost', port: 12540, prefix: '/websocket'
var _this = this;
return new Promise(function (resolve, reject) {
_this.sock = new SockJS('http://' + url + ':' + port + prefix);
_this.sock.onopen = resolve.bind(null, _this);
_this.sock.onmessage = _this._message.bind(_this);
_this.sock.onclose = _this._close.bind(_this);
});
};
server
Net.prototype.start = function(port, prefix) { //port: 12540, prefix: '/websocket'
this.sockjs = Sockjs.createServer({ sockjs_url: 'http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js' });
var server = http.createServer();
this.sockjs.installHandlers(server, {prefix: prefix});
server.listen(port, '0.0.0.0');
return this;
};
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 27 (9 by maintainers)
Links to this issue
Commits related to this issue
- Do not reply with Allow-Origin '*' for null Origin Otherwise local files do not work because of CORS issues, see https://github.com/sockjs/sockjs-node/issues/177 — committed to novoselt/sockjs-tornado by novoselt 9 years ago
- fix cors issue - when origin is null, cors should return null origin. https://github.com/sockjs/sockjs-node/issues/177 — committed to paulhovey/sockjs-go by paulhovey 9 years ago
@ivan-kleshnin @KyleAMathews @garrettmaring @Genffy I just published
sockjs-node 0.3.16
. Sorry about the major delay.@KyleAMathews sorry I haven’t released this yet. Work has been crazy because we just launched a product.