fix(index-builder): add _redirects to route / → app.html

The replay viewer was baked into index.html (served at /) while the
leaderboard app was at /app.html. Add a _redirects file so visitors
landing on / get redirected to the main leaderboard app.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-04-25 07:22:06 -04:00
parent 992fa1d573
commit 5d89fbd885

View file

@ -107,6 +107,16 @@ func verifyMergedOutput(cfg *Config) error {
slog.Warn("leaderboard.json not yet generated, deploying with partial data")
}
// Ensure _redirects routes / → app.html so the main leaderboard app is the
// entry point. The replay viewer stays at /index.html for direct linking.
redirectsPath := filepath.Join(cfg.OutputDir, "_redirects")
if _, err := os.Stat(redirectsPath); err != nil {
redirectsContent := "/ /app.html 301\n"
if writeErr := os.WriteFile(redirectsPath, []byte(redirectsContent), 0644); writeErr != nil {
slog.Warn("Failed to write _redirects", "error", writeErr)
}
}
slog.Info("Merged output verified", "directory", cfg.OutputDir)
return nil
}