Next.js Discord

Discord Forum

I added `middleware.ts` to my NextJS NextAuth project and it's not working

Answered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
Am I not supposed to get redirected to the sign in page with these lines of code? I'm not sure why it's not redirecting me.

middleware.ts
export { default } from "next-auth/middleware"

export const config = { matcher: ["/"] }
Answered by Transvaal lion
You're supposed to put the middleware.ts under the src folder. I was putting it in the wrong place. Now it's working.
View full answer

1 Reply

Transvaal lionOP
You're supposed to put the middleware.ts under the src folder. I was putting it in the wrong place. Now it's working.
Answer