Railway Issue with NextJS API Proxy

lightshirePRO

a year ago

Hi,

we have a railway nextjs APP that proxies /api/ to another application.

I seem to know the fix, but I dont know the nginx template that nextjs uses with railway.

I am getting: Error 400 - Request Header Or Cookie Too Large (nginx)

I think I just to increase the nginx config to like this

http {
  ...
  client_body_buffer_size     32k;
  client_header_buffer_size   8k;
  large_client_header_buffers 8 64k;
  ...
}

How can I do it? Where is the nginx template for nextjs I can use?

Awaiting User Response

5 Replies

lightshirePRO

a year ago

Here is the screenshot as well

Attachments


a year ago

Are you proxying /api/ to the other service via the private network? if not, definitely should be (assuming the application is another service in your project)


lightshirePRO

a year ago

no, its outside and its another endpoint. its using nextjs proxy feature


a year ago

Gotcha, then you would need to configure the proxy on that application, but I'm honestly not seeing how Railway or a nginx template on Railway come into play here?


Hey! Could you elaborate on your setup? Did you deploy from a Railway template?

Next deploys on Railway are not proxied via nginx by default, so I'm curious where that error is coming from.

nextjs proxy feature

Do you mean Next's rewrite feature?