diff --git a/.changeset/hot-socks-beg.md b/.changeset/hot-socks-beg.md new file mode 100644 index 000000000..77050c885 --- /dev/null +++ b/.changeset/hot-socks-beg.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +Middleware move permanently fix diff --git a/packages/next-on-pages/templates/_worker.js/routes-matcher.ts b/packages/next-on-pages/templates/_worker.js/routes-matcher.ts index c00b22b7a..6e7f04044 100644 --- a/packages/next-on-pages/templates/_worker.js/routes-matcher.ts +++ b/packages/next-on-pages/templates/_worker.js/routes-matcher.ts @@ -215,6 +215,12 @@ export class RoutesMatcher { // to continue and did not rewrite/redirect the URL. this.body = resp.body; this.status = resp.status; + } else if ( + resp.headers.has('location') && + resp.status >= 300 && + resp.status < 400 + ) { + this.status = resp.status; } applyHeaders(this.headers.normal, resp.headers);