fix: SPA routing and prompts table handling
- Add clean URL routing: /dashboard -> dashboard.html, /settings -> settings.html - Add EnsurePromptsTable for dev environments where prompts table may not exist - Fix nav links to use clean URLs instead of .html paths Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,12 +38,28 @@ func main() {
|
||||
// Initialize handlers
|
||||
handlers.Init(cfg)
|
||||
|
||||
// Ensure prompts table exists for dev environments
|
||||
db.EnsurePromptsTable()
|
||||
|
||||
// Setup routes
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Static files (frontend)
|
||||
fs := http.FileServer(http.Dir("frontend"))
|
||||
mux.Handle("/", fs)
|
||||
// Static files with SPA-style routing for HTML pages
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
// Map clean URLs to .html files
|
||||
switch path {
|
||||
case "/dashboard":
|
||||
http.ServeFile(w, r, "frontend/dashboard.html")
|
||||
return
|
||||
case "/settings":
|
||||
http.ServeFile(w, r, "frontend/settings.html")
|
||||
return
|
||||
}
|
||||
// Default file server
|
||||
fs := http.FileServer(http.Dir("frontend"))
|
||||
fs.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
// Auth routes (no auth required)
|
||||
mux.HandleFunc("POST /api/auth/login", handlers.Login)
|
||||
|
||||
Reference in New Issue
Block a user