From e8bdf5e77e0d2f376a477074f31627f4031a9282 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Mon, 18 Dec 2023 16:00:23 +0100 Subject: [PATCH 1/3] fix: try to match errors, fall back to just adding raw key / value pair instead --- packages/open-next/src/adapters/routing/matcher.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/open-next/src/adapters/routing/matcher.ts b/packages/open-next/src/adapters/routing/matcher.ts index 32a910d92..44f4aa4d5 100644 --- a/packages/open-next/src/adapters/routing/matcher.ts +++ b/packages/open-next/src/adapters/routing/matcher.ts @@ -105,9 +105,14 @@ export function addNextConfigHeaders( const fromSource = match(source); const _match = fromSource(rawPath); headers.forEach((h) => { - const key = convertMatch(_match, compile(h.key), h.key); - const value = convertMatch(_match, compile(h.value), h.value); - requestHeaders[key] = value; + try { + const key = convertMatch(_match, compile(h.key), h.key); + const value = convertMatch(_match, compile(h.value), h.value); + requestHeaders[key] = value; + } catch { + debug("Error matching header ", h.key, ' with value ', h.value); + requestHeaders[h.key] = h.value; + } }); } } From 94aa9fd10d2e333ffdbd8f3cf093ccac795111a9 Mon Sep 17 00:00:00 2001 From: Dorseuil Nicolas Date: Fri, 5 Jan 2024 16:24:36 +0100 Subject: [PATCH 2/3] changeset --- .changeset/afraid-ducks-speak.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/afraid-ducks-speak.md diff --git a/.changeset/afraid-ducks-speak.md b/.changeset/afraid-ducks-speak.md new file mode 100644 index 000000000..6150cf75e --- /dev/null +++ b/.changeset/afraid-ducks-speak.md @@ -0,0 +1,5 @@ +--- +"open-next": patch +--- + +try to match errors, fallback to raw key/value pair From 3d0026a644d593227c8f1e4f8b90172e917f5a80 Mon Sep 17 00:00:00 2001 From: Dorseuil Nicolas Date: Fri, 5 Jan 2024 16:28:32 +0100 Subject: [PATCH 3/3] fix lint --- packages/open-next/src/adapters/routing/matcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/open-next/src/adapters/routing/matcher.ts b/packages/open-next/src/adapters/routing/matcher.ts index 44f4aa4d5..d77e47b5b 100644 --- a/packages/open-next/src/adapters/routing/matcher.ts +++ b/packages/open-next/src/adapters/routing/matcher.ts @@ -110,7 +110,7 @@ export function addNextConfigHeaders( const value = convertMatch(_match, compile(h.value), h.value); requestHeaders[key] = value; } catch { - debug("Error matching header ", h.key, ' with value ', h.value); + debug("Error matching header ", h.key, " with value ", h.value); requestHeaders[h.key] = h.value; } });