Skip to content

Commit 78046e5

Browse files
authored
Fix incorrect CORS failure detection logic (#23844)
Regression of #23495 Fixes #23838 Fixes #23850
1 parent 6e58f84 commit 78046e5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/public/public.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func AssetsHandlerFunc(opts *Options) http.HandlerFunc {
4545
return
4646
}
4747

48-
var corsSent bool
4948
if opts.CorsHandler != nil {
49+
var corsSent bool
5050
opts.CorsHandler(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
5151
corsSent = true
5252
})).ServeHTTP(resp, req)
53-
}
54-
// If CORS is not sent, the response must have been written by other handlers
55-
if !corsSent {
56-
return
53+
// If CORS is not sent, the response must have been written by other handlers
54+
if !corsSent {
55+
return
56+
}
5757
}
5858

5959
file := req.URL.Path[len(opts.Prefix):]

0 commit comments

Comments
 (0)