'Cypress intercept threw cross origin error with supplied statusCode

I'm using Cypress 6.3.0. Why does the following happen?

cy.intercept('https://some.random.url', {
  statusCode: 200
})

threw a Cypress detected a cross origin error happened on page load error

but

cy.intercept('http://some.random.url')

did not.



Solution 1:[1]

You have two different protocols there in the code snippets you quote: https vs http. This is possibly tripping Cypress up.

Solution 2:[2]

As mentioned in the cypress docs setting chromeWebSecurity to false in your configuration file (cypress.json by default) will solve this issue.

{
  "chromeWebSecurity": false
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Große
Solution 2