Combine custom middleware function with next-auth withAuth
Unanswered
Goldstripe sardinella posted this in #help-forum
Goldstripe sardinellaOP
Hello everyone,
So far I have been using next-auth's
Now I want to add a custom middleware function for other routes and I am struggling to understand how I can do it.
I would intuitively to keep
Thank you for your help!
So far I have been using next-auth's
withAuth middleware to redirect users to a custom log in page on a couple of routes:export default withAuth({
pages: {
signIn: `/auth/signin`,
},
});
export const config = { matcher: ['/api/form', '/submit'] };Now I want to add a custom middleware function for other routes and I am struggling to understand how I can do it.
I would intuitively to keep
withAuth as it seems safer than implementing the same logic manually. But from next-auth's documentation it isn't clear how that should be done: do I wrap withAuth in a middleware function? and, if so, how do I pass the pages object? Thank you for your help!