Cloudflare DevelopersCD
Cloudflare Developers15mo ago
2 replies
Rokas

Pages middleware with nextjs and wrangler pages dev

Hello, I have a nextjs app, that uses app router. I've tried adding pages middleware to it, but I just cannot get it to work locally.

I've added functions/_middleware.ts file in the root of the project, right next to package.json. It's just an example copied over from the docs with an additional console.log.

I run command: pnpm wrangler pages dev

When I hit any route, I don't see any logs from my middleware.

What kinda worked is running wrangled command like this: pnpm wrangler pages dev .next/static - now middleware gets hit and I see the logs, but any route I try to access, I get 404s.

What am I missing?
Was this page helpful?