KindeK
Kinde2y ago
12 replies
ruby

redirect from root "/" with middleware in next.js

I want to make a classic stuff, i have a SaaS with a landing page and some routes, a login and after auth here then you are redirect to dashboard... until here everything okay, but i want to make like vercel, is you are authenticate and you go to vercel.com then they redirect you to /dashboard, easy i think... but i cant be able to do that, if i include "/" in the matcher, i am forced to move to login page... and if not include then the function inside middleware is not execute... currently i have this, i prefer have everything about protected routes manage in middleware so i dont really want to explore another fix in the main page or in every single routes of my web...
image.png
Was this page helpful?