question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.location.replace not working - inserts `__` into url

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
flotwigcommented, May 21, 2020

This fix is available starting in 4.6.0 as an experiment which you can access by setting this config option in your cypress.json or elsewhere:

{
	"experimentalSourceRewriting": true
}

The fix is experimental, so there may be some situations where the _/ rerouting is not fixed.

If you’re still experiencing _/ rerouting while setting the experimentalSourceRewriting to true in 4.6.0 - open a new issue with a reproducible example + screenshots, etc - filling out our issue template.

1reaction
laurentenhoorcommented, Jun 2, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found