-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle external middleware rewrites (#568)
- Loading branch information
1 parent
bc216b4
commit 8ece962
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
'@cloudflare/next-on-pages': patch | ||
--- | ||
|
||
fix external middleware rewrites | ||
|
||
Currently Middleware rewrites (`NextResponse.rewrite()`) assume that the rewrite destination | ||
is on the same host as the application, meaning that the following operations would work as intended: | ||
|
||
```ts | ||
NextResponse.rewrite(new URL('/rewrite-dest', request.url)); | ||
``` | ||
|
||
while something like this would not: | ||
|
||
```ts | ||
return NextResponse.rewrite( | ||
new URL('https://my-customer-rewrite-site.come/rewrite-dest', request.url), | ||
); | ||
``` | ||
|
||
Remove such assumption and allow such external rewrites to take place (as they do on Vercel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters