You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using rewrites() in next.config.js to proxy API requests to an internal backend server, the Accept-Encoding header is lost before it reaches the destination. This prevents our backend from returning compressed responses (e.g. gzip or br).
I confirmed the request passes through Next.js middleware with Accept-Encoding still present, but by the time it hits the internal server, it's gone.
Is this expected?
What’s the correct way to preserve the original Accept-Encoding?
Request is confirmed to go through Next.js middleware, and Accept-Encoding is visible at that point.
However, when it reaches http://internal-api.mycompany.local, Accept-Encoding is missing.
We rely on this header to return compressed responses, so we'd like to know how to preserve it correctly when using rewrites.
Next.js 15 with App Router and Middleware enabled.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
When using rewrites() in next.config.js to proxy API requests to an internal backend server, the Accept-Encoding header is lost before it reaches the destination. This prevents our backend from returning compressed responses (e.g. gzip or br).
I confirmed the request passes through Next.js middleware with Accept-Encoding still present, but by the time it hits the internal server, it's gone.
Is this expected?
What’s the correct way to preserve the original Accept-Encoding?
Additional information
// next.config.js
// Client request:
Request is confirmed to go through Next.js middleware, and Accept-Encoding is visible at that point.
However, when it reaches http://internal-api.mycompany.local, Accept-Encoding is missing.
We rely on this header to return compressed responses, so we'd like to know how to preserve it correctly when using rewrites.
Next.js 15 with App Router and Middleware enabled.
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions