Skip to content

Commit e773e67

Browse files
fix: try to match errors, fall back to just adding raw key / value pare (#336)
* fix: try to match errors, fall back to just adding raw key / value pair instead * changeset * fix lint --------- Co-authored-by: Dorseuil Nicolas <[email protected]>
1 parent fd90b26 commit e773e67

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/afraid-ducks-speak.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+
try to match errors, fallback to raw key/value pair

packages/open-next/src/adapters/routing/matcher.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ export function addNextConfigHeaders(
105105
const fromSource = match(source);
106106
const _match = fromSource(rawPath);
107107
headers.forEach((h) => {
108-
const key = convertMatch(_match, compile(h.key), h.key);
109-
const value = convertMatch(_match, compile(h.value), h.value);
110-
requestHeaders[key] = value;
108+
try {
109+
const key = convertMatch(_match, compile(h.key), h.key);
110+
const value = convertMatch(_match, compile(h.value), h.value);
111+
requestHeaders[key] = value;
112+
} catch {
113+
debug("Error matching header ", h.key, " with value ", h.value);
114+
requestHeaders[h.key] = h.value;
115+
}
111116
});
112117
}
113118
}

0 commit comments

Comments
 (0)