mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-14 11:17:28 +08:00
Allow credentialed cross-origin API requests
This commit is contained in:
@@ -245,6 +245,7 @@ func (s *Server) withCORS(next http.Handler) http.Handler {
|
||||
} else {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
}
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
allowMethods := strings.TrimSpace(r.Header.Get("Access-Control-Request-Method"))
|
||||
if allowMethods == "" {
|
||||
allowMethods = "GET, POST, PUT, PATCH, DELETE, OPTIONS"
|
||||
|
||||
Reference in New Issue
Block a user