Cypress 14 web app that uses a typical SSO login flow with a redirect-based OAuth process. #31528
Unanswered
singhGrewal
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The issue:
By the time Cypress finishes the cy.visit() to the app, the browser has already been redirected to the login origin.
If I then try to run:
I get this error:
cy.origin() requires the first argument to be a different origin than top.
Because Cypress is already on the login origin, the call is rejected.
example
What I’ve tried:
• Wrapping cy.visit() inside cy.origin() to preempt the origin switch — this sometimes works but feels brittle
• Capturing cy.url() after the redirect and calling cy.origin() dynamically — fails because I’m already on the new origin
• injectDocumentDomain: true — this works but is deprecated and not ideal for long-term support
What’s the best Cypress-supported pattern for:
• Handling SSO or OAuth flows that redirect to a different origin?
• Making sure cy.origin() is called before Cypress gets auto-redirected?
• Maintaining reliability across environments (e.g., staging, CI)?
Any guidance or patterns you’d recommend would be greatly appreciated
Beta Was this translation helpful? Give feedback.
All reactions