Middlware not running next 16.1.6
Unanswered
Netherland Dwarf posted this in #help-forum
Netherland DwarfOP
Hi, my proxy file is not running. I have version 16.1.6, and named the file proxy in the root level of my app.
14 Replies
Netherland DwarfOP
export default clerkMiddleware(async (auth, request: NextRequest) => {
throw new Error('Middleware error test');
});
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
};thats my middleware
named proxy.ts
@Netherland Dwarf Hi, my proxy file is not running. I have version 16.1.6, and named the file proxy in the root level of my app.
can you tell your exact file structure
if you are using src dir, you are supposed to place it inside src/proxy.[js|ts]
@Anay-208 if you are using src dir, you are supposed to place it inside src/proxy.[js|ts]
Netherland DwarfOP
I am using app directory no src
/app
proxy.ts
proxy.ts
But apaprently I figured it out
It is clerk's middleware callback, it does not allow pipelines responses
hence why none of the logic worked
I verified it by just exporting a proxy function and no middlware
However, I did hear that it is bad practice to use proxy.ts for heavy computation.
As that is next.js team recommendation to keep it simple and fast
But where would I handle rate limiting then?