fix: handle pre-flight requests

This commit is contained in:
talksik
2026-03-18 07:56:08 -07:00
parent 51857bed63
commit ff785f409f
2 changed files with 44 additions and 1 deletions
+5 -1
View File
@@ -119,9 +119,13 @@ func main() {
mux.Handle("POST /depot/upload", withAuth(h.PrepareUpload))
mux.Handle("POST /depot/objects/{id}/confirm", withAuth(h.ConfirmUpload))
// Apply middleware
// nil allows all origins (required for electron app)
muxWithCors := middleware.CORS(nil)(mux)
addr := fmt.Sprintf("0.0.0.0:%s", port)
slog.Info("running server", "addr", addr)
if err := http.ListenAndServe(addr, mux); err != nil {
if err := http.ListenAndServe(addr, muxWithCors); err != nil {
slog.Error("server failed", "error", err)
os.Exit(1)
}