Skip to content

Commit

Permalink
chore: only set Access-Control-Allow-Credentials when it’s true (#41
Browse files Browse the repository at this point in the history
)
  • Loading branch information
unknwon authored Aug 20, 2023
1 parent 12a4662 commit f568113
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ func CORS(options ...Options) flamego.Handler {
u.Scheme = opt.Scheme
}
headers["Access-Control-Allow-Origin"] = u.String()
headers["Access-Control-Allow-Credentials"] = strconv.FormatBool(opt.AllowCredentials)
headers["Vary"] = "Origin"

if opt.AllowCredentials {
headers["Access-Control-Allow-Credentials"] = "true"
}
}

ctx.ResponseWriter().Before(func(w flamego.ResponseWriter) {
Expand Down

0 comments on commit f568113

Please sign in to comment.