Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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/hip-bags-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

fix: Ensure the protocol is correct for redirects in server actions during preview mode
8 changes: 8 additions & 0 deletions packages/cloudflare/src/cli/templates/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ function populateProcessEnv(url: URL, env: CloudflareEnv) {
port: url.port,
},
});

/* We need to set this environment variable to make redirects work properly in preview mode.
* Next sets this in standalone mode during `startServer`. Without this the protocol would always be `https` here:
* https://github.com/vercel/next.js/blob/6b1e48080e896e0d44a05fe009cb79d2d3f91774/packages/next/src/server/app-render/action-handler.ts#L307-L316
*/
if (url.hostname === "localhost") {
process.env.__NEXT_PRIVATE_ORIGIN = url.origin;
}
}

/* eslint-disable no-var */
Expand Down