Skip to content

Error: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' #177

Closed
@DavidBM

Description

@DavidBM

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;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions