Custom response headers go away while returning i18nRouter(request, i18nConfig);
mehul64 opened this issue · 6 comments
Hi,
When returning i18nRouter(request, i18nConfig);
in the middleware, it returns it's own NextResponse. What if we have done customizations to our response (like adding headers to it) before calling the return i18nRouter(request, i18nConfig);
. In that case the newly set headers (customizations) are gone and it returns it's own response. Is there a workaround to it ?
I have the same situation, i18nRouter is overriding all the changes I make to the response object
i18nRouter returns a response. Could you not take the response returned from i18nRouter and make your customizations on it?
The thing is I'm adding headers to the response object before calling i18nRouter. With NextJs the response object is global so changes made to the response would be available across the app. For example if I'm adding headers to the response in the middleware I expect to see these headers later on.
I'm not sure I understand. Can you provide an example?
Are you currently accessing the response like this? const response = NextResponse.next()
Why not just do const response = i18nRouter(config)
?
Stale
Request headers are now forwarded in v5.1.0