question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Found HTTP 431 (Request Header Fields Too Large) when stubbing XHR request on Cypress 3.6.0

See original GitHub issue

Current behavior:

Cypress returns HTTP 431 (Request Header Fields Too Large) when stubbing response with cy.route() command.

After deep down to check my XHR request, it sends only 2 fields in request headers which are Accept: "application/json, text/plain, */* and Authorization: Bearer <token> The request URL is matched with wildcard pattern e.g. http://localhost/api/artist/*

Desired behavior:

cy.route() should return stubbed data and http status as configured in the command.

Steps to reproduce: (app code and test code)

App code just send a request with axios.get('url');

Test code stub that url with cy.route() command like this:

cy.fixture('path/to/fixture/response_body.json').then(resp => {
   cy.route({
       method: 'GET',
      url: <url with wildcard matched>,
      status: 200,
      response: resp 
   })
})

Run with Chrome 78

Versions

Cypress 3.6.0 Node 8.16.2

I try the workaround by adding NODE_OPTIONS=--max-http-header-size=1000000 before executing cypress run. it works properly.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
case12commented, May 4, 2020

Seeing the same. Status 431 on a request with a long Authorization key in the header. Fixed by passing NODE_OPTIONS=--max-http-header-size=1000000

0reactions
flotwigcommented, May 4, 2020

@case12 Upgrade to Cypress 4.3.0 or later, this was fixed in #5988 - the default --max-http-header-size in Cypress is now 1MB

The OP should also be resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix HTTP Error 431 Request Header Fields Too Large
The number 431 indicates the specific HTTP error, which is “Request Header Fields Too Large.” Essentially, this means that the HTTP request ......
Read more >
HTTP Error 431: 3 Ways to Fix Request Header Fields Too ...
The HTTP Error 431: Request Header Fields Too Large response status code indicates that the origin server refuses to fulfill users' requests.
Read more >
Changelog - Cypress Documentation
Use the cy.intercept() command to stub network responses and requests. ... header now displays correctly when there are a large number of successful...
Read more >
How to fix 431 Request Header Fields Too Large in React ...
I had faced the same issue in my Angular Application. After spending a lot of time, I had found out that the issue...
Read more >
cypress-io/cypress - Gitter
Some of my (very long) AJAX requests in Chrome in Cypress get HTTP status 431 Request Header Fields Too Large. 11 replies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found