alpe78
BABetter Auth
•Created by alpe78 on 5/7/2025 in #help
Middleware not working?
Hi all,
i guess i have a very common use case. but as i am new to better auth maybe you can give me some hints.
Stack T3 Stack with better-auth, drizzle, trpc.
Usecase:
my app is a "backendonly" app which means that only the loginform is shown to the public.
next is: my users can have 2 different roles "user" and "admin"
any user has to login before he can see something.
- /page.tsx => Loginform
- /user/page.tsx => Protected Userpage
- /admin/page.tsx => Protected Adminpage
now the i tried to use a middleware to protect those routes:
middleware.ts
but i get this error when im logged in:
i already tried as well to add the runtime, but i get another error
so im thinking that it is not the preferrable way to protect routes.
can you give me some hints how to solve or implement such usecases.
is it better to write or use plugins?
9 replies