diff --git a/backend/main.go b/backend/main.go index 8902264..742fce3 100644 --- a/backend/main.go +++ b/backend/main.go @@ -28,13 +28,16 @@ func main() { } } - // Create a middleware for CORS + // Create a middleware for CORS - allow all origins corsMiddleware := func(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - // Set CORS headers - w.Header().Set("Access-Control-Allow-Origin", "http://localhost:5173") - w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + // Set CORS headers to allow any origin + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE") + w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With") + w.Header().Set("Access-Control-Max-Age", "3600") + + // Handle preflight OPTIONS requests if r.Method == http.MethodOptions { w.WriteHeader(http.StatusOK) return