Unable to access middleware before initialization
Hello I am trying to launch on vercel but i keep getting an issue using the latest version of tanstack
I'm using router and tanstack start for server functionality and i keep getting the following error:
[request error] [unhandled] [GET] https://tanstack-ume-ume-gih3m7v73-ume-projects.vercel.app/
ReferenceError: Cannot access 'dbMiddleware' before initialization
To give more context in dbMiddleware. I define this inside of server/middleware/auth-middleware.ts
this is then used in server functions using the following:
I'm hoping somebody might be able to help me or has ran into a similar issue.
4 Replies
optimistic-gold•3mo ago
can you share a reproducer for this please ?
rival-blackOP•3mo ago
Hi manuel i actually figured it out, you can't call server functions from better auth lib haha
optimistic-gold•3mo ago
what do you mean?
rival-blackOP•3mo ago
Dang you responded fast, been busy over here i'm sorry.
So i'm using better-auth and i was calling a server function from a hook within the library. This seemed to create a circular dependency.
However i have even more issues with vercel now, i'm using MUI and it keeps giving me to many files open when trying to launch on vercel