angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

SecurityError: Failed to execute 'pushState' #326

Closed rolandjitsu closed 9 years ago

rolandjitsu commented 9 years ago

I keep getting a SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'http:' cannot be created in a document with origin 'http://localhost:3000' as in the screenshot below:

image

but I am unsure why. With version 22 of angular alpha I do not get that, but with version 23 I do. Could it be something with parsing the url?

EDIT: I tried debugging a bit and where these lines of code are:

pushState: function(state, title, url) {
    this._history.pushState(state, title, url);
}

I can see that the url is // as the screenshot below shows:

screenshot 2015-05-19 09 54 40

I think that might be why I get the error, but could the reason be because of the url?

NOTE: After further debugging, I think the problem might be somewhere along these lines:

go: function(url) {
    var finalUrl = url[0] == '/' ? url : this._baseHref + '/' + url;
    this._browserLocation.pushState(null, '', finalUrl);
}

Because the url argument in my case is "", which means that url[0] == '/' condition will not work as expected.

rolandjitsu commented 9 years ago

I've updated to alpha version 25 and it seems to be working now. I've managed to get a simple repo up and running using the router.