diff options
author | Michael Hunteman <huntemanmt@gmail.com> | 2025-01-31 12:32:09 -0600 |
---|---|---|
committer | Michael Hunteman <huntemanmt@gmail.com> | 2025-01-31 12:32:09 -0600 |
commit | 6150d079ea06ba55e5f145b67f02065d94b757f9 (patch) | |
tree | d8994e3793fc55e052c7d7a780112b323128de13 /server/cmd/main.go | |
parent | ff05f3941721de3ff343421968422d216d82e952 (diff) |
Improve logging and error handling
Diffstat (limited to 'server/cmd/main.go')
-rw-r--r-- | server/cmd/main.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/server/cmd/main.go b/server/cmd/main.go index f9da6ce..7b2310a 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -52,7 +52,7 @@ func serveHTTP(handler http.Handler) http.Handler { } func writeMethods(responseWriter http.ResponseWriter, request *http.Request) { - allowedMethods := []string{"OPTIONS", "POST", "PUT"} + allowedMethods := []string{"OPTIONS", "POST", "PUT", "GET", "DELETE"} method := request.Header.Get("Access-Control-Request-Method") if isPreflight(request) && slices.Contains(allowedMethods, method) { responseWriter.Header().Add("Access-Control-Allow-Methods", method) @@ -60,9 +60,8 @@ func writeMethods(responseWriter http.ResponseWriter, request *http.Request) { } func writeOrigins(responseWriter http.ResponseWriter, request *http.Request) { - allowedOrigins := []string{"http://localhost:5173"} origin := request.Header.Get("Origin") - if slices.Contains(allowedOrigins, origin) { + if origin == "http://localhost:5173" { responseWriter.Header().Add("Access-Control-Allow-Origin", origin) } } |