Skip to content

Can't get headers if using middleware #363

Answered by amannn
rizkiandrianto asked this question in Q&A
Discussion options

You must be logged in to vote

You can't call NextResponse.next() again, that's what the next-intl middleware does internally. Response headers can be added as illustrated in the docs.

If you need to read an additional request header in one of your components, you need to set them before you're calling the next-intl middleware.

Here's a fixed version of your example: https://codesandbox.io/p/sandbox/determined-bird-4n5577?file=%2Fsrc%2Fapp%2F%5Blocale%5D%2Fpage.tsx%3A6%2C47

/cc @barbarah since you've commented below.

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
7 replies
@rizkiandrianto
Comment options

@amannn
Comment options

Answer selected by rizkiandrianto
@barbarah
Comment options

@amannn
Comment options

@barbarah
Comment options

@rizkiandrianto
Comment options

Comment options

You must be logged in to vote
2 replies
@amannn
Comment options

@barbarah
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working unconfirmed Needs triage.
4 participants
Converted from issue

This discussion was converted from issue #362 on June 28, 2023 14:29.