Can't get headers if using middleware #363
-
DescriptionWhen I'm using Am I missing something? Mandatory reproduction URL (CodeSandbox or GitHub repository)Reproduction descriptionSteps to reproduce:
Expected behaviourShould be based on thrown headers based on |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
It seems like you're linking to the unmodified App Router example, I don't see any broken behavior there. I'm also not sure what your inquiry is, are you looking to add an additional response header (see the middleware docs)? I'll convert this to a discussion since this looks like a usage question, I hope you understand. |
Beta Was this translation helpful? Give feedback.
-
I have a similar issue. I have a custom header set in the middleware. This header was working in |
Beta Was this translation helpful? Give feedback.
You can't call
NextResponse.next()
again, that's what thenext-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.