(next http.Handler)
| 238 | } |
| 239 | |
| 240 | func corsMiddleware(next http.Handler) http.Handler { |
| 241 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 242 | w.Header().Set("Access-Control-Allow-Origin", "http://localhost:5173") |
| 243 | w.Header().Set("Access-Control-Allow-Methods", "GET, PUT, OPTIONS") |
| 244 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type") |
| 245 | |
| 246 | if r.Method == http.MethodOptions { |
| 247 | w.WriteHeader(http.StatusNoContent) |
| 248 | return |
| 249 | } |
| 250 | |
| 251 | next.ServeHTTP(w, r) |
| 252 | }) |
| 253 | } |