Fix SSG compatibility: fallback /path.html to /path/index.html
All checks were successful
TypeScript CI / build (push) Successful in 36s
Deploy to R2 / deploy (push) Successful in 1m46s

Astro and other SSG frameworks generate /path/index.html instead of /path.html.
Added fallback logic so /products resolves to /products/index.html when
/products.html doesn't exist in R2.
This commit is contained in:
Heimdall
2026-04-01 04:47:54 +00:00
parent 903348fb96
commit 2c9c36c40c

View File

@@ -523,7 +523,17 @@ export default {
const key = `sites/${customer}${filePath}`;
try {
const object = await env.BUCKET.get(key);
let object = await env.BUCKET.get(key);
// Fallback: /path.html → /path/index.html (Astro 등 SSG 호환)
if (!object && filePath.endsWith('.html') && filePath !== '/index.html') {
const dirPath = filePath.replace(/\.html$/, '/index.html');
const dirKey = `sites/${customer}${dirPath}`;
object = await env.BUCKET.get(dirKey);
if (object) {
filePath = dirPath;
}
}
if (!object) {
if (filePath === '/index.html') {