Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using base tag, react-router and redux-devtools, Uncaught SecurityError: Failed to execute 'pushState' on 'History' occurs #234

Closed
narr opened this issue Feb 18, 2016 · 6 comments

Comments

@narr
Copy link

narr commented Feb 18, 2016

When base tag is used like "http://localhost:3000/", in addBasename function from useBasename.js
location.basename is set to '/' and location.pathname is also set to '/' if the location.pathname is '/'.
The problem is that when it reverts to the path '/' by redux-devtools with react-router, it uses locationBeforeTransitions object which is the location object from history and the path becomes '//' in finishTransition function from createBrowserHistory.js and it cause an error like below at window.history.pushState(historyState, null, path) in finishTransition function.

Uncaught 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'.

I guess location.pathname should be set '/' only when location.basename is not '/' so that the path in finishTransition function will be '/'.
screen shot 2016-02-18 at 3 52 30 pm

@taion
Copy link
Contributor

taion commented Feb 18, 2016

The correct fix here is probably to use addBasename in transitionTo on useBasename.

That said, we're not going to accept a PR here without tests.

@GabiAxel
Copy link

This also happened to me when trying to replace('/') from React Router onEnter and base="/".

@mjackson
Copy link
Member

mjackson commented May 3, 2016

Looks like conversation has stalled here.

@mjackson mjackson closed this as completed May 3, 2016
@mwq27
Copy link

mwq27 commented May 6, 2016

I'm having this same problem. Was there a solution?

@jonaskello
Copy link

jonaskello commented Oct 5, 2016

Having the same issue. Any solution yet? Have read several other issues that states what the problem is, for example here and here.

@JMStudiosJoe
Copy link

My solution was taking path from one state
var helloState = {
name: 'hello',
url: '/login',
component: LoginComponent
}
and changing it to
var helloState = {
name: 'hello',
url: '#/login',
component: LoginComponent
}

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants