medium

CypressError: cy.origin() — Visiting a cross-origin URL

Cypress cannot visit a different domain within the same test by default. Cross-origin navigation requires the cy.origin() command.

Common Causes

  1. 1Test navigates to a third-party login page (e.g., OAuth)
  2. 2Application redirects to a different domain
  3. 3iframes load content from a different origin

How to Fix

Use cy.origin() for cross-domain flows

cy.visit('/login');
cy.get('#oauth-button').click();

cy.origin('https://accounts.google.com', () => {
  cy.get('#email').type('[email protected]');
  cy.get('#next').click();
});

cy.origin() allows executing commands on a different domain within the same test.

How ObserveOne Helps

ObserveOne supports cross-origin test flows and monitors OAuth/SSO integrations for failures.

Start Monitoring Free

Related Errors