MugetsuM
tRPC4y ago
17 replies
Mugetsu

NextJs middleware broken by tRPC

Hi, I have a NextJs middleware that is redirecting to the login page. Basically an Auth guard over my all pages and apis but I have a problem with tRPC api routes. Whenever NextJs middleware pickup /api/trpc call and there is no session it tries to redirect to the login page breaking the redirect and trpc itself. Is there a way to get this working so redirect would actually work as expected?
Screenshot_2022-10-25_at_01.30.47.png
Was this page helpful?