cypress: Change of origin fails on all browsers except Firefox
Current behavior
In the attached spec I’m registering at my site then attempting to log into https://ethereal.email to check for the registration email. The registration succeeds but logging into Ethereal fails with “Error invalid csrf token” at the Ethereal site using any browser other than Firefox.
Desired behavior
Logging into Ethereal.email should succeed after the registration process on all browsers.
Test code to reproduce
- Using the attached script, rename .txt to .js.
- Use a baseURL of https://test-hecho-en-todos-santos.pantheonsite.io
- Create an account at Ethereal and change this line in the spec: const userEmail = ‘adaline.littel54@ethereal.email’
- Run the script with a browser other than Firefox.
- You should see the error. But if you restart back at line 3 and use Firefox it will work.
Cypress Version
12.9.0
Node version
16.16.0
Operating System
macOS 13.3.
Debug Logs
Debug output included above.
Other
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 19 (3 by maintainers)
Thanks for providing this, @hankszeto. I just pinged Cypress in Discord to bring it to their attention, the goal being to get a solution into the main Cypress build.
@alfonsodev @aangelinsf
The hint is in the warning provided by Chrome:
It looks like the reason why this is happening is because:
ethereal.email
) differs from the address in the URL bar of the Cypress test runner (which is the address of my local DDEV instance,https://myway-3.ddev.site:8443/
)I got this working by intercepting the Set-Cookies header and enforcing
SameSite=None; Secure
.Here is the code:
@aangelinsf Ah I see. Good call. I have simplified your example down even further to see if testing the Ethereal login flow is an issue in Cypress.
This login appears it works fine outside of
cy.origin()
It seems like something is getting dropped / missing when using
cy.origin()
specifically with visiting Ethereal. I will flag as a bug and route to the team.