Where should I place middleware? (following T3 app tutorial video)

I was placing middleware inside 'src' folder (like what Theor mentioned) but it kept routing me to a unknown url instead of localhost:3000.. So instead I placed the middleware in the root folder (as it's mentioned in the Clerk docs: https://clerk.com/docs/nextjs/trpc#configure-middleware) and it appears to be working fine since I can see the purple background. Not sure whether this is correct tho..
TRPC | Clerk
Learn how to integrate Clerk into your Next.js with TRPC
1 Reply
whatplan
whatplan2y ago
https://nextjs.org/docs/pages/building-your-application/routing/middleware
Use the file middleware.ts (or .js) in the root of your project to define Middleware. For example, at the same level as pages or app, or inside src if applicable.
Routing: Middleware
Learn how to use Middleware to run code before a request is completed.
Want results from more Discord servers?
Add your server