Request Header Fields Too Large
erikskrt
PROOP

a year ago

Hey Everyone! Set up a next.js rewrite from my NextJS application

myapp.io/api/ -> the railway URL

Unfortunately the cookie size is very large due to JWTs and we're getting Request Header Fields Too Large. The backend doesn't even need to use this cookie, and there's no way to omit it from NextJS's end without creating and paying for custom middleware.

Is there any way to set up Railway to ignore the Cookie header? instead of returning the Request Header Fields Too Large error

16 Replies

erikskrt
PROOP

a year ago

dfca2de8-200c-4fbb-b74c-74a8a8ee1296


a year ago

can you provide a screenshot of this error?


erikskrt
PROOP

a year ago

yes


erikskrt
PROOP

a year ago


erikskrt
PROOP

a year ago

can reproduce with the URL i sent above as well if it helps


erikskrt
PROOP

a year ago

i think you can only reproduce if logged into joylink.io actually since that's what sets the cookie


a year ago

iirc the header limit is 8KB, i can't see us increasing that anymore unfortunately


erikskrt
PROOP

a year ago

any way to make it just reject headers over the limit


a year ago

we do not provide that kind of functionality


a year ago

Hi, the solution to this is (unfortunately) better token design. You should only be storing core information in the JWT token anyways, such as a unique identifier for the user and the barebones information that is required to make the site work. For example, if you're storing the entire user object in the JWT and only accessing the SUB (uid) for authentication (assuming your payload is signed), you should really only be storing the SUB on that token.


a year ago

>Unfortunately the cookie size is very large due to JWTs and we're getting Request Header Fields Too Large. The backend doesn't even need to use this cookie, and there's no way to omit it from NextJS's end without creating and paying for custom middleware.


a year ago

I can't read


a year ago

Can you tell me which cookie it is?


a year ago

Oh well, I can't even sign into it because "API Key required" or something


a year ago

oh well


a year ago

Pretty cool product tho btw


Welcome!

Sign in to your Railway account to join the conversation.

Loading...