Failed to execute 'replaceState' on 'History'
See original GitHub issueVersion
react-router 1.0.0
Dependencies
history 1.13.1
Error
Chrome:
DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL 'http:' cannot be created in a document with origin 'http://localhost:8080' and URL 'http://localhost:8080/select'.
at Error (native)
at finishTransition (http://localhost:8080/app.js:38970:27)
at http://localhost:8080/app.js:35432:14
at http://localhost:8080/app.js:35408:10
at done (http://localhost:8080/app.js:35725:15)
at next (http://localhost:8080/app.js:35734:13)
at Object.loopAsync (http://localhost:8080/app.js:35738:4)
at confirmTransitionTo (http://localhost:8080/app.js:35394:18)
at Object.transitionTo (http://localhost:8080/app.js:35420:6)
at http://localhost:8080/app.js:36771:24
Firefox:
Unhandled promise rejection DOMException [SecurityError: "The operation is insecure."
code: 18
nsresult: 0x80530012
location: http://multiline-admin.zipwhip.com/app.js:61]
I’m getting an error only when using the browser history (i.e. not hash history) . This is happening in a then() of a promise returned from an async action like this:
handleLogin(credentials) {
login(credentials)
.then(() => {
this.context.history.replaceState("/select");
});
}
So pretty much a standard redirect after login scenario. All I’ve found relating to the error above seems to be around a change in the host/origin which is not happening in this case.
- The URL in the address bar is changed (i.e. it does have the path of “/select”) but the UI does not update to reflect this.
- Other links in the app work fine
- Other invocations of
histroy.replace()are working - I have exposed the
historyobject viawindow.__historyandwindow.__history.replace("/select")works
Any ideas?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
DOMException: Failed to execute 'replaceState' on 'History'
The answer is based on the react-loadable-ssr-addon's examples, the idea here is to check window.location.origin with your domain's origin.
Read more >Failed to execute 'replaceState' on 'History' #3184 - GitHub
DOMException : Failed to execute 'replaceState' on 'History': A history state object with URL 'http:' cannot be created in a document with ...
Read more >Uncaught DOMException: Failed to execute 'replaceState' on ...
"Uncaught DOMException: Failed to execute 'replaceState' on 'History': A history state object" is appears after going to Dashboards page. Build: 2020.3.9754.
Read more >Failed to execute 'pushState' on 'History' - Kirby forum
Failed to execute 'pushState' on 'History': A history state object with URL 'http://127.0.0.1:8989/panel/system' cannot be created in a ...
Read more >Failed to execute 'replaceState' on 'History', iframe and two ...
When I access mysite on its own, all good. When trying to go thru this site (acsbace), it puts it in an iframe,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you can’t do
pushorreplacewith something likehttp:..., only the path, likepush('/somewhere')not `push(‘http://whatever/somewhere’)It looks like it is because there is a second call happening and passing
"/"which is getting appended tobasenameof"/"resulting in the double-slash path in the history module.