Skip to content

Commit d3caf91

Browse files
authored
Middleware move permanently fix (#810)
1 parent fa751e3 commit d3caf91

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/hot-socks-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudflare/next-on-pages': patch
3+
---
4+
5+
Middleware move permanently fix

packages/next-on-pages/templates/_worker.js/routes-matcher.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ export class RoutesMatcher {
215215
// to continue and did not rewrite/redirect the URL.
216216
this.body = resp.body;
217217
this.status = resp.status;
218+
} else if (
219+
resp.headers.has('location') &&
220+
resp.status >= 300 &&
221+
resp.status < 400
222+
) {
223+
this.status = resp.status;
218224
}
219225

220226
applyHeaders(this.headers.normal, resp.headers);

0 commit comments

Comments
 (0)