Skip to content

Commit 0cf7eb3

Browse files
committed
fix(converters): Ensure x-forwarded-proto is set to http when running locally
1 parent 0e25eb1 commit 0cf7eb3

File tree

1 file changed

+6
-0
lines changed
  • packages/open-next/src/overrides/converters

1 file changed

+6
-0
lines changed

packages/open-next/src/overrides/converters/edge.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const converter: Converter<InternalEvent, InternalResult | MiddlewareResult> = {
3636
? (cookieParser.parse(cookieHeader) as Record<string, string>)
3737
: {};
3838

39+
// This is to make libraries (e.g. next-auth) that rely on this header to work out of the box in `opennextjs-cloudflare preview`.
40+
// See https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/lib/utils/env.ts#L95-L96
41+
if (url.hostname === "localhost") {
42+
headers["x-forwarded-proto"] = url.protocol.slice(0, -1); // Remove the trailing ':'
43+
}
44+
3945
return {
4046
type: "core",
4147
method,

0 commit comments

Comments
 (0)