I'm trying to login to my app using cypress.io, but am getting the error "Mismatched Origin".
According to the documentation, we can bypass CORS by setting chromeWebSecurity:false
inside our cypress.json
, but I'm still getting CORS errors.
https://docs.cypress.io/guides/references/error-messages.html#Page-Load-Errors
Cypress documentation discourages logging in using the UI, so I'm using the cy.request()
method as follows:
Here is my cypress.json
file:
{
"chromeWebSecurity": false,
"baseUrl": "http://localhost:1234"
}
Here is my test.js
file:
method: 'POST',
url: 'http://localhost:3000/login',
body: {
username: 'user',
password: 'password',
credentails: 'include',
headers: {'Allow-Control-Allow-Origin': "*"}
}
})
And the error from Cypress:
Status: 400 - Bad Request
Headers: {
"server": "BaseHTTP/0.6 Python/3.7.9",
"date": "Thu, 24 Dec 2020 00:49:06 GMT",
"content-length": "30",
"content-type": "application/json"
}
Body: {
"error": "Mismatched origin."
}
I'm wondering if anyone has had luck making a request to a service on a different port to login to in Cypress? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire