8 months ago
I see that users receive 431 HTTTP error when visiting my next.js website
Is it possible to configure variable that define the length of headers? (e.g. client_header_buffer_size or something like that).
5 Replies
Status changed to Awaiting User Response railway[bot] • 9 months ago
8 months ago
I just see that users can experience this problem. For me it's not a case and I don't see a way to reproduce it. By it seems to happen if cookies size is larger than server can accept (I don't know specific limitation set on the server, probably 2-4 Kb)
From development side, I am trying to reduce the size of cookies that we set after authorization. But probably other services are also creating large cookies (e.g. we use Posthog for analytics). And that's why when cookies size reach some critical point, users receive 431 http error.
Attachments
Status changed to Awaiting Railway Response railway[bot] • 9 months ago
8 months ago
linking this stackoverflow thread if it helps: https://stackoverflow.com/questions/686217/maximum-on-http-header-values
Usually this limit is handled by the webserver, but I've also asked our infra team to check if this could be coming from our proxy (my assumption is, it shouldn't, and would be something from your website. but it also doesn't look like a classic nextjs error)
I'll keep you updated
Status changed to Awaiting User Response railway[bot] • 9 months ago
8 months ago
After investigation, it seems to me that issue is related to posthog
https://medium.com/@hadikusumahendrawan/fixing-431-header-too-large-error-posthog-integration-best-practices-7ea0fd7ee6a3
https://posthog.com/tutorials/cookieless-tracking
I am trying to fix it, by changing persistence init parameter
Status changed to Awaiting Railway Response railway[bot] • 9 months ago
8 months ago
Posthog seems to be setting multiple cookies instead of a single one. As a number of cookies grows, at some point error is reached
Attachments
Status changed to Solved itsrems • 8 months ago