Next.js Discord

Discord Forum

Top level password nextjs

Unanswered
Lawrence's Goldfinch posted this in #help-forum
Open in Discord
Lawrence's GoldfinchOP
Hi
I am trying to add a simple browser level password like old school ftp servers to my nextjs app. I am already using next-auth with Google Provider for my admin page and have used middleware.ts

But I have problem figuring out how to use different middlewares for different purposes.

Any help/guide would be greatly appreciated.

Thanks

11 Replies

@linesofcode https://github.com/instantcommerce/next-password-protect
Lawrence's GoldfinchOP
Thanks for this. I had seen this one but not sure how it can help me . I already have a middleware.ts with exported {default} and one line of matcher
I want to add a single password regardless of any other auth implemented to the entire website
That’s what the package I posted above does
You’ll need to ignore its routes in the middleware
Btw you’ll likely need a custom middleware
If you want to exclude certain pages but not other pages based on a condition
Inside of the middleware you can use getToken function from next auth
To do the auth check
@linesofcode Inside of the middleware you can use getToken function from next auth
Lawrence's GoldfinchOP
Thanks very much. I will give it a try shorty