fix: serve /docs/*.md as static files, not SPA fallback

- Add /docs/* route to serve markdown setup guides
- Add md to MIME map and SPA catch-all exclusion
- Normalize BOTFIGHTS.md placeholders to YOUR_BOT_ID/YOUR_BOT_SECRET

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-13 16:16:44 +00:00
co-authored by Claude Opus 4.6
parent a571ff4b98
commit 2e7a039b8b
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -125,6 +125,7 @@ if (process.env.NODE_ENV === 'production' && existsSync(publicDir)) {
wav: 'audio/wav',
mp3: 'audio/mpeg',
ogg: 'audio/ogg',
md: 'text/markdown',
}
function serveFile(c: Context, reqPath: string, cacheControl: string) {
@@ -163,6 +164,9 @@ if (process.env.NODE_ENV === 'production' && existsSync(publicDir)) {
app.get('/icon.svg', (c) => serveFile(c, '/icon.svg', 'public, max-age=86400'))
app.get('/apple-touch-icon.png', (c) => serveFile(c, '/apple-touch-icon.png', 'public, max-age=86400'))
// Docs (markdown setup guides)
app.get('/docs/*', (c) => serveFile(c, c.req.path, 'public, max-age=3600'))
// Audio files (pre-generated TTS, SFX)
app.get('/audio/*', (c) => serveFile(c, c.req.path, 'public, max-age=86400'))
// SPA fallback: only for navigation requests (not JS/CSS/asset files)
@@ -170,7 +174,7 @@ if (process.env.NODE_ENV === 'production' && existsSync(publicDir)) {
if (c.req.path.startsWith('/api/')) return c.notFound()
// Don't serve index.html for asset requests — return 404 so the browser gets a proper error
const ext = c.req.path.split('.').pop()
if (ext && ext !== c.req.path && ['js', 'css', 'map', 'json', 'png', 'jpg', 'svg', 'woff', 'woff2', 'webp', 'ico', 'wav', 'mp3', 'ogg'].includes(ext)) {
if (ext && ext !== c.req.path && ['js', 'css', 'map', 'json', 'png', 'jpg', 'svg', 'woff', 'woff2', 'webp', 'ico', 'wav', 'mp3', 'ogg', 'md'].includes(ext)) {
return c.notFound()
}
const indexPath = join(publicDir, 'index.html')