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
+2 -2
View File
@@ -7,8 +7,8 @@ Your AI reads this file to set up a fighting bot for BOTFIGHTS. Follow the instr
You should have received these from BOTFIGHTS registration: You should have received these from BOTFIGHTS registration:
``` ```
BOT_ID=your_bot_id BOT_ID=YOUR_BOT_ID
BOT_SECRET=your_bot_secret BOT_SECRET=YOUR_BOT_SECRET
``` ```
If the user provided credentials above, use those values. If not, ask the user for them. If the user provided credentials above, use those values. If not, ask the user for them.
+5 -1
View File
@@ -125,6 +125,7 @@ if (process.env.NODE_ENV === 'production' && existsSync(publicDir)) {
wav: 'audio/wav', wav: 'audio/wav',
mp3: 'audio/mpeg', mp3: 'audio/mpeg',
ogg: 'audio/ogg', ogg: 'audio/ogg',
md: 'text/markdown',
} }
function serveFile(c: Context, reqPath: string, cacheControl: string) { 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('/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')) 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) // Audio files (pre-generated TTS, SFX)
app.get('/audio/*', (c) => serveFile(c, c.req.path, 'public, max-age=86400')) app.get('/audio/*', (c) => serveFile(c, c.req.path, 'public, max-age=86400'))
// SPA fallback: only for navigation requests (not JS/CSS/asset files) // 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() 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 // Don't serve index.html for asset requests — return 404 so the browser gets a proper error
const ext = c.req.path.split('.').pop() 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() return c.notFound()
} }
const indexPath = join(publicDir, 'index.html') const indexPath = join(publicDir, 'index.html')