visiting `https` then `http` of same subdomain fails saying you can only visit a single unique domain per test
See original GitHub issuewhat_it_does:
CypressError: cy.visit() failed because you are attempting to visit a second unique domain.
You may only visit a single unique domain per test.
Different subdomains are okay, but unique domains are not.
The previous domain you visited was: 'https://www.sina.com.cn'
You're attempting to visit this new domain: 'http://sports.sina.com.cn'
http://sports.sina.com.cn is subdomain , but error. https://sports.sina.com.cn is ok.
Current behavior:
Desired behavior:
Steps to reproduce: (app code and test code)
Versions
Cypress: 3.8.0 │ Browser: Electron 78 (headless)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cypress: How to visit a url of a different origin? - Stack Overflow
I did work for me but cypress fails the test after routing to the new url, throwing Cypress detected a cross origin error...
Read more >Same-origin policy - Web security | MDN
The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a ......
Read more >Web Security - Cypress Documentation
If you attempt to visit two different superdomains, the cy.origin command must be used to wrap Cypress commands of the second visited domain....
Read more >Subdomain Visit Count - LeetCode
A count-paired domain is a domain that has one of the two formats "rep d1.d2.d3" or "rep d1.d2" where rep is the number...
Read more >Fully Qualified Domain Name (FQDN): Complete Guide With ...
Does your site have a fully qualified domain name? Learn more about FQDNs and why they're important with our complete guide.
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
Why
Ok, so, after discussing this with the team, this is actually expected behavior.
The rules for what we have been calling a ‘single unique domain per test’ are technically following the rules of Same Origin Policy as outlined here: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
So visiting a different protocol (
http
tohttps
) is not considered the same protocol.The reason the
http
tohttps
often works is because of the websites rerouting rules.Next steps
same origin policy
. This error message should be updated.http
andhttps
specifically being the same and following the rules. https://on.cypress.io/trade-offs#Same-origin I’ve created an issue to update this here: https://github.com/cypress-io/cypress-documentation/issues/2364Released in
4.1.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v4.1.0, please open a new issue.