window.location.replace not working - inserts `__` into url
See original GitHub issueCurrent behavior:
Navigating within our application using location.replace("")
in a chained promise handler throws a cross-origin error. In our actual application, we are waiting on a network request, then navigating using location.replace()
in a then handler.
I’ve simplified the code to the most basic thing I can, and am able to reproduce by calling location.replace()
in a simple setTimeout
.
window.location.replace("")
– works
setTimeout(() =>{
window.location.replace("");
});
– gives the following error: SecurityError: Blocked a frame with origin "http://localhost:58236" from accessing a cross-origin frame.
Desired behavior:
I need to be able to call location.replace()
in a chained promise handler.
Steps to reproduce: (app code and test code)
https://github.com/beckee/cypress-test-tiny
Versions
Cypress 3.2.0 Mac OSX Chrome Version 73
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:20 (7 by maintainers)
Top Results From Across the Web
window.location.replace() not working to redirect browser
I was trying to load another page from the same domain, but was using an absolute URL (e.g. www.example.com/newurl ). I changed it...
Read more >location replace or window.location doesn't work
Hi. I'am trying to use in javascript thé command location.replace or window.location.href to go to anothet page with param, but unfortunately these command ......
Read more >location.replace() - Web APIs - MDN Web Docs
The replace() method of the Location interface replaces the current resource with the one at the provided URL. The difference from the ...
Read more >Get URL and URL Parts in JavaScript - CSS-Tricks
JavaScript can access the current URL in parts. ... solution for your problem might just be to change location with a String.replace() call ......
Read more >How do I redirect my web page with JavaScript? - Tutorialspoint
A web page can be redirected using JavaScript by using the window.location.assign() function. This procedure redirects to the newly added URL ...
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 FreeTop 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
Top GitHub Comments
This fix is available starting in
4.6.0
as an experiment which you can access by setting this config option in yourcypress.json
or elsewhere:The fix is experimental, so there may be some situations where the
_/
rerouting is not fixed.If you’re still experiencing
_/
rerouting while setting theexperimentalSourceRewriting
to true in 4.6.0 - open a new issue with a reproducible example + screenshots, etc - filling out our issue template.@jennifer-shehane it has been filed here: https://github.com/cypress-io/cypress/issues/7565