package api import ( "net/http" ) const defaultAllowedOrigin = "http://localhost:5173" func withCORS(next http.Handler) http.Handler { return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { writer.Header().Set("Access-Control-Allow-Origin", defaultAllowedOrigin) writer.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS") writer.Header().Set("Access-Control-Allow-Headers", "Content-Type") if request.Method == http.MethodOptions { writer.WriteHeader(http.StatusNoContent) return } next.ServeHTTP(writer, request) }) } func NewRouter() http.Handler { mux := http.NewServeMux() mux.HandleFunc("GET /health", HealthHandler) mux.HandleFunc("GET /api/v1/status", StatusHandler) return withCORS(mux) }