Skip to content

Commit c0ee44b

Browse files
committed
fix(vercel): properly parse x-now-route-matches header
1 parent 6baa4ef commit c0ee44b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/presets/vercel/runtime/vercel.web.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ export default {
1111
context: { waitUntil: (promise: Promise<any>) => void }
1212
) {
1313
// Check for ISR request
14-
const isrRoute = req.headers.get("x-now-route-matches");
15-
if (isrRoute) {
16-
const url = new URL(req.url);
17-
url.pathname = decodeURIComponent(isrRoute);
18-
req = new Request(url.toString(), req);
14+
const query = req.headers.get("x-now-route-matches");
15+
if (query) {
16+
const urlParam = new URLSearchParams(query).get("url");
17+
if (urlParam) {
18+
const url = new URL(decodeURIComponent(urlParam), req.url).href;
19+
req = new Request(url, req);
20+
}
1921
}
2022

2123
// srvx compatibility

0 commit comments

Comments
 (0)