how to use dynamic routes in middleware.js #5036
Unanswered
dhavalveera
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
Hello,
I was looking in the NextAuth documentation to protect the pages using the middleware.js file, and I found the code snippet from NextAuth's Documentation.
here, I have a question, as in matcher it passes the regular page (file) name, but how to protect the dynamic pages? e.g.
/pages/[productId]/index.js
or/pages/product/[index].js
, how to protect those kinds of pages using the middleware.js file?also, as per the example shared above, if I hit the
URL/dashboard
page directly then it'll redirect to the Login page, then after successful Login, does it'll redirect back to the Dashboard Page?also, if I use a Custom Login Page instead of NextAuth's default Login Page, then this
middleware
will work the same way?please explain/help me here.
How to reproduce ☕️
nothing to re-produce
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions