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 diff --git a/packages/open-next/src/adapters/routing/matcher.ts b/packages/open-next/src/adapters/routing/matcher.ts index 32a910d92..d77e47b5b 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; + } }); } }