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

Understand why chromeWebSecurity: false is needed #181

Open
scottohara opened this issue May 25, 2020 · 2 comments
Open

Understand why chromeWebSecurity: false is needed #181

scottohara opened this issue May 25, 2020 · 2 comments

Comments

@scottohara
Copy link
Owner

As described in the Cypress docs, same-origin policy can cause issues with cross-origin iframes etc.

However we don't use cross-origin iframes, navigate to other domains or perform any JS redirects. We're an SPA with client-side routing, and the URL never changes.

So it is unclear why we still need to set chromeWebSecurity: false in our cypress.json config?

Without this setting, when calling cy.visit("/#!/some/route"); (which should not change the origin or do anything with iframes), we get the following error:

loot

Would like to understand why Cypress thinks this is a cross-origin frame.

@scottohara
Copy link
Owner Author

Suspecting it may be something to do with the /#!/ in the path, also tried different combinations of:

// cypress.json - "baseUrl": "http://localhost:5000"

cy.visit("/#!/accounts");
// cypress.json - "baseUrl": "http://localhost:5000/#!"

cy.visit("/accounts");
// cypress.json - "baseUrl": "http://localhost:5000/#!/"

cy.visit("accounts");

Same result each time.

@scottohara
Copy link
Owner Author

scottohara commented Dec 17, 2021

On further inspection (after having removed & re-added chromeWebSecurity: false numerous times) is that setting this option controls the --disable-web-security command-line argument when launching Chrome:

https://github.com/cypress-io/cypress/blob/f79bdd665ada815fbfa238baac7a66c38d3b5d82/packages/server/lib/browsers/chrome.ts#L405-L408

In turn, this command-line argument controls numerous things in Chrom(e|ium), including CORS.

Another error we have seen is cannot set property name of which has only a getter, which is resolved by disabling web security.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant