fix: rebase _routes.json for Cloudflare when config.base set (#6473)

This commit is contained in:
Richard Simpson 2023-03-13 09:58:21 -05:00 committed by GitHub
parent a13e9d7e33
commit 1c3e8f6c3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---
fix automatic routes generation not respecting config.base

View file

@ -153,7 +153,12 @@ export default function createIntegration(args?: Options): AstroIntegration {
.map((file: string) => `/${file}`); .map((file: string) => `/${file}`);
for (let page of pages) { 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 const redirectsExists = await fs.promises