Is middleware supposed to be invoked twice for each request? #329
-
I'm trying to write a middleware function that calls a remote endpoint if a certain route is hit. When deployed to Cloudflare though I can see that the endpoint is called twice from the middleware, I was then able to see the fact that middleware is invoked twice for each request even with a simple middleware like so:
I can see two "got url" log entries for each request in the Cloudflare Pages Functions debugger. Is this expected behaviour? EDIT: I've noticed that in .vercel/output/config.json there are two
If I remove the second one from the built bundle |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hey there, thank you for raising this. It's an interesting point. The config at If it's not too much trouble, do you know if your middleware is invoked twice when deployed to Vercel? |
Beta Was this translation helpful? Give feedback.
-
I'm closing the discussion as I believe it to be solved 🙂 |
Beta Was this translation helpful? Give feedback.
Thank you for checking @madjam002, I appreciate it. I've opened a PR that I believe should resolve this problem, can you please try out the prerelease in #337 (comment)?