T
TanStack3mo ago
rival-black

Global Middleware not working in prod

Hello, I have global-middleware.ts, with registerGlobalMiddleware at the end. I import ./global-middleware from server.ts (I also tried importing it from router.tsx). The middleware runs fine in development, but not in production (I added log to the middleware functions to check). Anyone else experience this?
1 Reply
rival-black
rival-blackOP3mo ago
It's placed in src/global-middleware.ts next to router.tsx and server.ts. The global-middleware documentation mentions app/global-middleware.ts though the examples all use src/, not app/ This is what is required. In package.json:
"sideEffects": [
"./src/global-middleware.ts"
],
"sideEffects": [
"./src/global-middleware.ts"
],

Did you find this page helpful?