We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a27f04 commit 6ea4e43Copy full SHA for 6ea4e43
.changeset/fuzzy-ads-rush.md
@@ -0,0 +1,5 @@
1
+---
2
+"wrangler": patch
3
4
+
5
+Reverse execution order of Pages Functions middlewares
packages/wrangler/pages/functions/template-worker.ts
@@ -45,8 +45,8 @@ type WorkerContext = {
45
function* executeRequest(request: Request, env: Env) {
46
const requestPath = new URL(request.url).pathname;
47
48
- // First, iterate through the routes and execute "middlewares" on partial route matches
49
- for (const route of routes) {
+ // First, iterate through the routes (backwards) and execute "middlewares" on partial route matches
+ for (const route of [...routes].reverse()) {
50
if (
51
route.methods.length &&
52
!route.methods.includes(request.method as HTTPMethod)
0 commit comments