Skip to content

Commit a7540fd

Browse files
authored
fix wrong locale in middleware (#502)
* fix locale in middleware * Create silly-hounds-admire.md
1 parent f62f538 commit a7540fd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/silly-hounds-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
fix wrong locale in middleware

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export async function handleMiddleware(
5959
): Promise<MiddlewareOutputEvent | InternalResult> {
6060
const { rawPath, query } = internalEvent;
6161
const normalizedPath = normalizeLocalePath(rawPath);
62+
// We only need the normalizedPath to check if the middleware should run
6263
const hasMatch = middleMatch.some((r) => r.test(normalizedPath));
6364
if (!hasMatch) return internalEvent;
6465
// We bypass the middleware if the request is internal
@@ -67,7 +68,7 @@ export async function handleMiddleware(
6768
const host = internalEvent.headers.host
6869
? `https://${internalEvent.headers.host}`
6970
: "http://localhost:3000";
70-
const initialUrl = new URL(normalizedPath, host);
71+
const initialUrl = new URL(rawPath, host);
7172
initialUrl.search = convertToQueryString(query);
7273
const url = initialUrl.toString();
7374
// console.log("url", url, normalizedPath);

0 commit comments

Comments
 (0)