diff options
author | 2023-03-13 09:58:21 -0500 | |
---|---|---|
committer | 2023-03-13 22:58:21 +0800 | |
commit | 1c3e8f6c3b839087aa51de2e2fb665cd907f2847 (patch) | |
tree | 798ae7c6fab055fb1c77383520af57fce9630b21 | |
parent | a13e9d7e33baccf51e7d4815f99b481ad174bc57 (diff) | |
download | astro-1c3e8f6c3b839087aa51de2e2fb665cd907f2847.tar.gz astro-1c3e8f6c3b839087aa51de2e2fb665cd907f2847.tar.zst astro-1c3e8f6c3b839087aa51de2e2fb665cd907f2847.zip |
fix: rebase _routes.json for Cloudflare when config.base set (#6473)
-rw-r--r-- | .changeset/sweet-cherries-tickle.md | 5 | ||||
-rw-r--r-- | packages/integrations/cloudflare/src/index.ts | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/.changeset/sweet-cherries-tickle.md b/.changeset/sweet-cherries-tickle.md new file mode 100644 index 000000000..70e6db104 --- /dev/null +++ b/.changeset/sweet-cherries-tickle.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +fix automatic routes generation not respecting config.base diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index a72e0db46..f87b701e9 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -153,7 +153,12 @@ export default function createIntegration(args?: Options): AstroIntegration { .map((file: string) => `/${file}`); for (let page of pages) { - staticPathList.push(prependForwardSlash(page.pathname)); + let pagePath = prependForwardSlash(page.pathname); + if (_config.base !== '/') { + const base = _config.base.endsWith('/') ? _config.base.substring(0, -1) : _config.base; + pagePath = `${base}${pagePath}`; + } + staticPathList.push(pagePath); } const redirectsExists = await fs.promises |