state management in middleware
Unanswered
Nile tilapia posted this in #help-forum
Nile tilapiaOP
I'm using custom server(express) with Next.js 14 (app router)
to handle auth in frontend i have to call backend api on every route change to validate token in nextjs middleware
is there any other option to handle auth state in nextjs that can be accessed in middleware (like useContext api)?
to handle auth in frontend i have to call backend api on every route change to validate token in nextjs middleware
is there any other option to handle auth state in nextjs that can be accessed in middleware (like useContext api)?
1 Reply
@Nile tilapia I'm using custom server(express) with Next.js 14 (app router)
to handle auth in frontend i have to call backend api on every route change to validate token in nextjs middleware
is there any other option to handle auth state in nextjs that can be accessed in middleware (like useContext api)?
I handle my authentication without using an express server. You can make rest calls inside of the middleware, create a auth/validate enpoint and hit it and make sure its still valid there.