Fix zip downloads by adding _routes.json for Cloudflare Pages Functions

Without _routes.json, the SPA fallback was serving index.html instead of
invoking the download Functions, causing zip downloads to return HTML.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-03-10 09:20:23 -07:00
co-authored by Claude Opus 4.6
parent 7d2d42da96
commit 3908cb397e
+10 -1
View File
@@ -255,7 +255,16 @@ function generateCFConfig(buildDir) {
`;
fs.writeFileSync(path.join(buildDir, '_redirects'), redirects);
console.log('✓ Generated Cloudflare Pages config (_headers, _redirects)');
// _routes.json: tell Cloudflare Pages which paths invoke Functions
// Without this, the SPA fallback serves index.html for function routes
const routes = {
version: 1,
include: ['/api/download/*'],
exclude: [],
};
fs.writeFileSync(path.join(buildDir, '_routes.json'), JSON.stringify(routes, null, 2));
console.log('✓ Generated Cloudflare Pages config (_headers, _redirects, _routes.json)');
}
/**