Next.js Discord

Discord Forum

Setting Dynamic Response Headers in Next.js App Router Based on External API Headers

Unanswered
Atlantic mackerel posted this in #help-forum
Open in Discord
Atlantic mackerelOP
I ran into a limitation while migrating to the Next.js App Router.

In the old Pages Router, we could set response headers inside getServerSideProps. However, in the App Router, this no longer works the same way. Headers are effectively read-only because of React Server Components and streaming.

I need to set a page response header based on a header returned from an external API.

Could you share your thoughts on how to handle this scenario?

2 Replies