Is it possible to pass a variable to the route handler in a custom middleware.ts file? (App router)
Unanswered
Forest bachac posted this in #help-forum
Forest bachacOP
Is it possible, in a custom middleware.ts file to pass a variable to the route handler?
Use case:
The middleware checks if the user is authenticated and if they are the route handler needs their username
Use case:
The middleware checks if the user is authenticated and if they are the route handler needs their username
5 Replies
European sprat
You can set cookies and headers in middleware
Forest bachacOP
could the user mess with that? like edit the header in between when the middleware sets it and the route handler checks it
if you set it on Middleware it will be passed to the routes without any user intervention anymore