7 months ago
I am encountering HTTP Error 431 Request Header Field(s) Too Large as a response from my app. My app logic sometimes requires the use of large cookies. Could you please let me know if there is a way to increase the header size limit on Railway?
Details:
Error Message: HTTP Error 431 Request Header Field(s) Too Large
Any guidance on resolving this issue would be greatly appreciated.
21 Replies
7 months ago
Railway does indeed have a header size limit, can you tell me what size your headers are and why they need to be so large?
7 months ago
what size your headers are:
somewhere between 8-12KB
why they need to be so large:
We are using Supabase as our backend and Nextjs as frontend...
According to Supabase's guide on using it with Nextjs it uses cookies to store the JWT token and with supabase in some cases (e.g user used google oauth) the token go that large
Status changed to Solved brody • 7 months ago
Status changed to Open brody • 7 months ago
7 months ago
No worries at all!
To answer your question about the header size needed: after investigating, we found that Supabase stores all the authentication providers (Google, Facebook, etc.) data and tokens in the cookies. To handle this, we need the limit to be 16KB.
7 months ago
I wanted to provide some additional context. Despite numerous attempts to find workarounds to reduce the header size (as this issue is blocking our operations with the users), we are encountering another issue that may be important for railway to handle. The native Next.js behavior when dealing with URL state is adding a header "next-router-state-tree" with the value of the current URL in URL-encoded format. This significantly increases the header size, which can become very large on its own.
Combining this with some mid-sized cookies, it's clear that we need an increased header size limit to handle these cases.
Thanks again for your help!
Attachments
7 months ago
Thank you for the number, our current header size is indeed in the range you say it is.
I will ask our engineer who built the proxy if we would be interested in accommodating larger header sizes, seems like this could be a fairly common occurrence given you are using supabase.
I'll get back to you about this on a work day!
7 months ago
Thanks for the consideration and time. Looking forward to your update.
7 months ago
Let me add to the thread another reason to accommodate larger header sizes...
The most used proxy server by Railway users I think is Caddy, which has a default header limit of 1MB. With the current limit in the Railway proxy, users (including me) are unable to utilize this feature from Caddy, which is disappointing TBH.
7 months ago
I love caddy, so that's interesting, I wonder what NGINX's default header size is.
Either way, I have a ticket for this and I'll be discussing it with the engineer who built the proxy today if they are available.
7 months ago
It's 8KB in Nginx. I hope we can also have the ability to use this config in Nginx while using Railway.
Hope the discussion ends with some good news today!
7 months ago
We should be fine to do 32KB, if we are able to get that out I'll let you know when it's live.
Unfortunately, I am not able to provide an ETA.
7 months ago
Appreciate you working on this and keeping me informed.
7 months ago
Will have to punt this for a bit, but we are still going to be looking into this.
7 months ago
We’ll be interested in getting back to using Railway once this change is made. It’s tough to feel like we found the perfect solution and then have to leave over a small config issue like this..
7 months ago
Further update here, we haven't been able to prioritise this change yet, our engineer who would make this change is currently tied up moving all domains onto our new proxy.
7 months ago
Scratch that last message, our engineer has just finished moving all domains to our new Edge proxy and has made the change to allow for a maximum combined header size of 32KB.
This change will be live across all proxy hosts within the hour!
7 months ago
That’s fantastic news! I really appreciate the quick turnaround on this. I’m looking forward to getting back to using Railway with the new header size limit. Thanks for all your help!
7 months ago
It would have been quicker but we where busy doing a massive domain migration.
I'd also like to preemptively say that we won't be able to do higher than 32KB at this time, since that change was plan wide meaning that trial users can also do 32KB worth of headers, once we have a way to make these kinds of changes on a per-account basis we could then increase the limit for specific Pro user's.
7 months ago
I understand, thanks for the clarification.
If we ever need more than 32KB, I think that would be a good reason for us to upgrade to a Pro account. Appreciate all your efforts in making this change!
7 months ago
No problem! going to mark as solved, if you need further help on this topic feel free to re-open!
Status changed to Solved brody • 7 months ago