Setting a new key in request object in nextjs middleware #70895
Unanswered
summit070
asked this question in
App Router
Replies: 1 comment
-
|
Set it as a cookie:
IIRC, as long as it is not set on the outgoing response, the client won't see it. Middleware and handlers, do not share the same JavaScript, runtime. Also your |
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.
-
// middleware.js export function middleware(request: NextRequest) { req.name = "foo"; return NextResponse.next(); }export default async function handler(req, res) { console.log( req.name ) //logs undefined // what can I do so that I can access the new properties // I put in the req object in the middlware file here? }So, as you can see above, req.name is undefined in the route handler. How do i solve this issue
Beta Was this translation helpful? Give feedback.
All reactions