Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-trains-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix(cloudflare): enable trailiing slash redirect
7 changes: 5 additions & 2 deletions packages/open-next/src/core/routing/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ export function handleRewrites<T extends RewriteDefinition>(
function handleTrailingSlashRedirect(
event: InternalEvent,
): false | InternalResult {
const url = new URL(event.url, "http://localhost");
const emptyBody = emptyReadableStream();
// When rawPath is `//domain`, `url.host` would be `domain`.
const url = new URL(event.rawPath, "http://localhost");

if (
// Someone is trying to redirect to a different origin, let's not do that
Expand All @@ -267,6 +267,9 @@ function handleTrailingSlashRedirect(
) {
return false;
}

const emptyBody = emptyReadableStream();

if (
NextConfig.trailingSlash &&
!event.headers["x-nextjs-data"] &&
Expand Down