Skip to content

Commit 7e643f3

Browse files
authored
Merge pull request #13 from haproxytech/branch_issue12
Fixed #12
2 parents 3727c71 + 70e48ae commit 7e643f3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

example/haproxy/cors.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ function cors_response(txn, allowed_methods, allowed_origins)
4141
local method = txn.sf:method()
4242
local origin = txn:get_priv()
4343

44-
-- Always vary on the Origin
45-
txn.http:res_add_header("Vary", "Accept-Encoding,Origin")
46-
4744
-- add headers for CORS preflight request
4845
if method == "OPTIONS" then
4946
core.Debug("CORS: preflight request OPTIONS")
@@ -65,6 +62,7 @@ function cors_response(txn, allowed_methods, allowed_origins)
6562
elseif contains(allowed_origins, origin:match("//([^/]+)")) then
6663
core.Debug("CORS: " .. origin .. " allowed")
6764
txn.http:res_add_header("Access-Control-Allow-Origin", origin)
65+
txn.http:res_add_header("Vary", "Accept-Encoding,Origin")
6866
else
6967
core.Debug("CORS: " .. origin .. " not allowed")
7068
end

0 commit comments

Comments
 (0)