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
The same behavior occurs on pages depending on whether they are using the nodejs or edge runtime.
Note: The header is included in the final response to the client, but the issue is route handlers cannot dependably run custom business logic based on a header set in the middleware.
The text was updated successfully, but these errors were encountered:
For lack of a current mechanism to pass a value from the middleware to the route handlers, @colinclerk has made the following writeup that provides snippets which can be used for this purpose:
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000
Binaries:
Node: 16.16.0
npm: 8.11.0
Yarn: 3.2.3
pnpm: N/A
Relevant packages:
next: 12.3.1-canary.5
eslint-config-next: 12.3.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Version 105.0.5195.125 (Official Build) (arm64)
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
Headers set by middleware are not consistently accessible to the route (api or page) across route types & environments.
The following list summarizes the behavior:
Prod:
Dev:
Expected Behavior
A header set by the middleware should be accessible via
req.headers.get()
or thereq.headers
object for all route types and on all environments.Link to reproduction
https://github.com/yourtallness/next-middleware-tests
To Reproduce
The sample app is deployed on vercel here.
The sample middleware sets a header:
The following table shows if the header can be read back in the route handler.
The same behavior occurs on pages depending on whether they are using the
nodejs
oredge
runtime.Note: The header is included in the final response to the client, but the issue is route handlers cannot dependably run custom business logic based on a header set in the middleware.
The text was updated successfully, but these errors were encountered: