Found HTTP 431 (Request Header Fields Too Large) when stubbing XHR request on Cypress 3.6.0
See original GitHub issueCurrent 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:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
@case12 Upgrade to Cypress 4.3.0 or later, this was fixed in #5988 - the default
--max-http-header-size
in Cypress is now 1MBThe OP should also be resolved.