Skip to content

Commit 8a8f9cd

Browse files
committed
fix(middleware): respect host protocol
1 parent 811bdc0 commit 8a8f9cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/open-next/src/core/routing/middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ export async function handleMiddleware(
5454
// We bypass the middleware if the request is internal
5555
if (internalEvent.headers["x-isr"]) return internalEvent;
5656

57+
const protocol = new URL(internalEvent.url).protocol;
5758
const host = internalEvent.headers.host
58-
? `https://${internalEvent.headers.host}`
59+
? `${protocol}//${internalEvent.headers.host}`
5960
: "http://localhost:3000";
61+
6062
const initialUrl = new URL(normalizedPath, host);
6163
initialUrl.search = convertToQueryString(query);
6264
const url = initialUrl.toString();

0 commit comments

Comments
 (0)