Protect client side routes in app created using t3, I am using Discord provider for auth.

I have used middleware but still I am not able to achieve this.
2 Replies
VinnyXL(EU)
VinnyXL(EU)3w ago
Can you share you middleware code? Did you assign a matcher?
VinnyXL(EU)
VinnyXL(EU)3w ago
In second thought, middleware runs on edge so its not going to cover client-side routing and authorization, which are not recommended anyway, those should happen server-side only. You should use an auth provider and auth guard to handle authorization. Theres a great answer here: https://stackoverflow.com/questions/67560587/how-to-protect-routes-in-next-js-next-auth You can find examples for auth provider and guard code pretty easily. gl
Stack Overflow
How to protect routes in Next.js next-auth?
I am trying to integrate authentication with next-auth library in an Application. I have been following the official tutorial given here https://github.com/nextauthjs/next-auth-example/. The proble...

Did you find this page helpful?