Next.js Discord

Discord Forum

How to setup my middleware

Answered
Bucovina Shepherd Dog posted this in #help-forum
Open in Discord
Bucovina Shepherd DogOP
Hey all. I am pretty new to next js. I am trying to setup my middleware to protect the /generator route from unauthorized users. How would i do this? Ive tried using docs and gpt but it didn't really give me anything
Answered by Anay-208 | Ping in replies
In matcher, just add “/generator”
View full answer

5 Replies

Bucovina Shepherd DogOP
Right now my middleware looks like this. This is a template from supabase docs
Someone told me i could protect my route inside my /generator/page.tsx file to escape troubles
Answer
And check the auth status in middleware function
If you don’t want to protect the added routes, remove it