From 36e211e1fa8211fb305e08f4f950d11236964e5f Mon Sep 17 00:00:00 2001 From: Dorseuil Nicolas Date: Sun, 1 Sep 2024 12:50:27 +0200 Subject: [PATCH 1/2] fix locale in middleware --- packages/open-next/src/core/routing/middleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/open-next/src/core/routing/middleware.ts b/packages/open-next/src/core/routing/middleware.ts index fcf83b501..5a04e2066 100644 --- a/packages/open-next/src/core/routing/middleware.ts +++ b/packages/open-next/src/core/routing/middleware.ts @@ -59,6 +59,7 @@ export async function handleMiddleware( ): Promise { const { rawPath, query } = internalEvent; const normalizedPath = normalizeLocalePath(rawPath); + // We only need the normalizedPath to check if the middleware should run const hasMatch = middleMatch.some((r) => r.test(normalizedPath)); if (!hasMatch) return internalEvent; // We bypass the middleware if the request is internal @@ -67,7 +68,7 @@ export async function handleMiddleware( const host = internalEvent.headers.host ? `https://${internalEvent.headers.host}` : "http://localhost:3000"; - const initialUrl = new URL(normalizedPath, host); + const initialUrl = new URL(rawPath, host); initialUrl.search = convertToQueryString(query); const url = initialUrl.toString(); // console.log("url", url, normalizedPath); From 8689f31d25b40fa6a6183ce1b7baa9153c97d29a Mon Sep 17 00:00:00 2001 From: conico974 Date: Thu, 5 Sep 2024 15:46:49 +0200 Subject: [PATCH 2/2] Create silly-hounds-admire.md --- .changeset/silly-hounds-admire.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silly-hounds-admire.md diff --git a/.changeset/silly-hounds-admire.md b/.changeset/silly-hounds-admire.md new file mode 100644 index 000000000..eaf2c1a5f --- /dev/null +++ b/.changeset/silly-hounds-admire.md @@ -0,0 +1,5 @@ +--- +"open-next": patch +--- + +fix wrong locale in middleware