Skip to content

Commit

Permalink
chore(middleware/cors): Add Vary header for non-CORS OPTIONS requests…
Browse files Browse the repository at this point in the history
… comment
  • Loading branch information
sixcolors committed Mar 26, 2024
1 parent 2770faa commit 8583dbb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion middleware/cors/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ func New(config ...Config) fiber.Handler {

// If it's a preflight request and doesn't have Access-Control-Request-Method header, it's outside the scope of CORS
if c.Method() == fiber.MethodOptions && c.Get(fiber.HeaderAccessControlRequestMethod) == "" {
// See comment in preflight section below
// Response to OPTIONS request should not be cached but,
// some caching can be configured to cache such responses.
// To Avoid poisoning the cache, we include the Vary header
// for non-CORS OPTIONS requests:
c.Vary(fiber.HeaderOrigin)
return c.Next()
}
Expand Down

0 comments on commit 8583dbb

Please sign in to comment.