Summer Sale! All accounts are 50% off this week.

skoobi's avatar
Level 13

Cypress 405 error

Morning... I keep getting a 405 error when running a sample test in Cypress.

Heres the error i'm getting. Any ideas?

cy.request() failed on:
http://my-awesome-app.test/cypress/artisan
The response we received from your web server was:
  > 405: Method Not Allowed
This was considered a failure because the status code was not 2xx or 3xx.
If you do not want status codes to cause failures pass the option: failOnStatusCode: false

Trying to run this in my example_spec.js:

it('works', () => {
    cy.visit('/').contains('Username');
});
0 likes
3 replies
skoobi's avatar
Level 13

So dug down a bit and it looks like its related to the CSRF, but can't get it to work still...

 259 | 
  260 |     return cy.csrfToken().then((token) => {
> 261 |         return cy.request({
      |                   ^
  262 |             method: 'POST',
  263 |             url: '/__cypress__/artisan',
  264 |             body: { command: command, parameters: parameters, _token: token },
siangboon's avatar

@skoobi csrf error usually hit 419, 405 method not allow is related to the request type, double check the route is POST or GET

wikorl's avatar

@skoobi did you manage to solve the problem? If yes how. I'm running into the same issue

Please or to participate in this conversation.