JustMaier/angular-signalr-hub

using URL with useDefaultPath:false throws CORS Error

msms007 opened this issue · 3 comments

by looking at the signalr code,looks like when URL is supplied, It is not necessary to pass the useDefaultPath:false object.

I am getting CORS issue when this flag is passed. No issues when the object with flag is not passed.

$.hubConnection(options.rootPath) WORKS.
$.hubConnection(options.rootPath, { useDefaultPath: false }); Throws CORS error.

SignalR code ref

if (!url || settings.useDefaultPath) {
url = (url || "") + "/signalr";
}

with this when a URL is passed, it doesn't require the flag.

Can you give me the url that it hits with and without useDefaultPath?

I have also face same issue. But when i change useDefaultPath to userDefaultPath then it work's for me.

If you enter a url with subdomain ex:
"localhost/test/" and set your rootPath signalR to assume the url "localhost/signalr" erroneously. To get around the problem I entered the code below before instantiating a hub ..

  var getUrl = $ .signalR.transports._logic.getUrl;
    
     $ .signalR.transports._logic.getUrl = function (connection, transport, reconnecting, poll, ajaxPost) {
         var url = getUrl (connection, transport, reconnecting, poll, ajaxPost);
         return connection.url + url.substring (url.indexOf (connection.appRelativeUrl) + connection.appRelativeUrl.length);
     };