Replies: 1 comment
-
That is exactly what I'm looking for, I'm struggling with passing user context from middleware to the page components (when using App Router), and passing it serialized in headers is something I'm trying to avoid |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
To empower the user and allow for more flexibility, more data should be available the same way
headers()
andcookies()
is.I know only of #47108, but I assume there are countless more issues and users who would want this.
Specifically, I am thinking about the following properties:
NextRequest.nextUrl
NextRequest.geo
Non-Goals
n/a
Background
Without further research, I have very quickly discovered the aforementioned issue (#47108), which also came with a work-around for this very specific problem. While most properties from the request could be serialized and put into a header, this is a less than optimal solution.
The only reason I could think of this not being implemented yet is a potentially too high overhead? I am not familiar with how async storage works precisely.
Proposal
I have traced the context's creation back to:
next.js/packages/next/src/server/async-storage/request-async-storage-wrapper.ts
Line 67 in a7837bd
A brief look at the two places where this method is called shows that the required information is available.
next.js/packages/next/src/server/future/route-modules/app-route/module.ts
Line 264 in a7837bd
next.js/packages/next/src/server/app-render/app-render.tsx
Line 1539 in a7837bd
I would be interested in working on this myself.
Beta Was this translation helpful? Give feedback.
All reactions