Fix incorrect CORS failure detection logic (#23844)

Regression of #23495

Fixes #23838
Fixes #23850
This commit is contained in:
wxiaoguang 2023-03-31 23:35:48 +08:00 committed by GitHub
parent 6e58f8400e
commit 78046e5137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -45,16 +45,16 @@ func AssetsHandlerFunc(opts *Options) http.HandlerFunc {
return return
} }
var corsSent bool
if opts.CorsHandler != nil { if opts.CorsHandler != nil {
var corsSent bool
opts.CorsHandler(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { opts.CorsHandler(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
corsSent = true corsSent = true
})).ServeHTTP(resp, req) })).ServeHTTP(resp, req)
}
// If CORS is not sent, the response must have been written by other handlers // If CORS is not sent, the response must have been written by other handlers
if !corsSent { if !corsSent {
return return
} }
}
file := req.URL.Path[len(opts.Prefix):] file := req.URL.Path[len(opts.Prefix):]