Implement Issue #2: Scheduling & Publishing #10

Merged
thatguygriff merged 10 commits from feature/issue-2-scheduling into main 2026-04-08 23:02:18 +00:00
Showing only changes of commit c78a35377a - Show all commits

View File

@@ -94,8 +94,25 @@ func New(db *sql.DB, jwtSecret string, staticDir string) http.Handler {
})
})
// Serve static React app for all other routes
r.Handle("/*", http.FileServer(http.Dir(staticDir)))
// Serve static React app for all other routes, with SPA fallback
r.Handle("/*", spaHandler(staticDir))
return r
}
// spaHandler serves static files from dir, falling back to index.html for
// paths that don't match a file on disk (so client-side routing works).
func spaHandler(dir string) http.HandlerFunc {
fs := http.Dir(dir)
fileServer := http.FileServer(fs)
return func(w http.ResponseWriter, r *http.Request) {
// Try to open the requested path as a static file.
if f, err := fs.Open(r.URL.Path); err == nil {
f.Close()
fileServer.ServeHTTP(w, r)
return
}
// Not a real file — serve index.html and let React Router handle it.
http.ServeFile(w, r, dir+"/index.html")
}
}