Next.js Discord

Discord Forum

Issue with max http header size and deployment on Amplify

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
I've been having an issue when I call fetch with our GraphQL server where we run into a situation where we get 413 which triggers our application to refetch infinitely (See first screenshot). The behaviour that causes this problem is from the GraphQL query string becoming longer. However our query string is stored in the body so I'm having trouble seeing how it affects the header being too large.

So, what we've done locally to fix this is add NODE_OPTIONS=--max-http-header-size=64555 next dev in our npm run start script which fixes the problem locally.

I'd like to replicate this for our build which is hosted on Amplify, but I can't get the same fix working. For reference, this is our base Amplify.yml build script

version: 1 frontend: phases: preBuild: commands: - npm ci build: commands: - env | grep -e NEXT_PUBLIC_ >> .env.production - npm run build artifacts: baseDirectory: .next files: - '**/*' cache: paths: - node_modules/**/*

I've tried doing NODE_OPTIONS=--max-http-header-size=64555 npm run build which hasn't seemed to work.

If anyone can offer some guidance on how to get this working or a proper fix for this, it would be greatly appreciated!

0 Replies