Search code examples
typescriptnext.jsmiddlewarenext.js13

Middleware not executing on Nextjs 13.4 app routing


I have a problem. My middleware doesn't get executed... This is my code:

export const config = {
  matcher: '/api/:function*',
};

This is the config I gave, it should only execute when the API gets a request. I have the middleware.ts file inside my app/ folder. Does someone know why this isn't working. I have the app routing version without the src/ folder selected.


Solution

  • Place middleware.ts in the src/ directory. It should be on the same level as app directory.