diff options
Diffstat (limited to 'middleware/auth.go')
| -rw-r--r-- | middleware/auth.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/middleware/auth.go b/middleware/auth.go index e4f096b..5025f32 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -154,4 +154,16 @@ func AdminMiddleware(next http.Handler) http.Handler { logging.SecurityLog.Info("ADMIN ACCESS GRANTED", "user", user.Username, "path", r.URL.Path, "ip", ip) next.ServeHTTP(w, r) }) +} + +// HandleOptions is a middleware that handles pre-flight OPTIONS requests. +// This should be placed before the CSRF middleware. +func HandleOptions(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodOptions { + w.WriteHeader(http.StatusOK) + return + } + next.ServeHTTP(w, r) + }) }
\ No newline at end of file |
