Fix route validation for Netlify Edge (#4722)

* fix: serialize route pattern for Netlify edge

Co-authored-by: Jackie Macharia <jackiewmacharia>

* chore: changeset
This commit is contained in:
Ben Holmes 2022-09-12 19:33:44 -04:00 committed by GitHub
parent 49006da077
commit 4bc70f3545
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---
Fix route validation failures on Netlify Edge

View file

@ -53,7 +53,10 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U
} else {
functions.push({
function: entryFile,
pattern: route.pattern.toString(),
// Make route pattern serializable to match expected
// Netlify Edge validation format. Mirrors Netlify's own edge bundler:
// https://github.com/netlify/edge-bundler/blob/main/src/manifest.ts#L34
pattern: route.pattern.source.replace(/\\\//g, '/').toString(),
});
}
}