Skip to content

Commit 55fc524

Browse files
authored
Added support for Allow Headers #492 (#493)
Co-authored-by: Domagoj Potkoc <[email protected]>
1 parent e5dbfd8 commit 55fc524

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: etc/fastly_edge_modules/cors_headers.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
"required": true,
2424
"type": "string"
2525
},
26+
{
27+
"description": "Allowed HTTP Headers that requestor can use",
28+
"label": "Allowed HTTP Headers",
29+
"name": "cors_allowed_headers",
30+
"required": false,
31+
"type": "string"
32+
},
2633
{
2734
"description": "Regex matching origins that are allowed to access this service",
2835
"label": "Regex matching origins",
@@ -39,7 +46,7 @@
3946
},
4047
"vcl": [
4148
{
42-
"template": " if (req.http.Origin && !resp.http.Access-Control-Allow-Origin && !resp.http.Access-Control-Allow-Methods) {\n{{#ifEq origin \"anyone\"}}\n set resp.http.Access-Control-Allow-Origin = \"*\";\n{{/ifEq}}\n{{#ifEq origin \"regex-match\"}}\n if ( req.http.Origin ~ \"^https?://{{cors_allowed_origins_regex}}\" ) {\n set resp.http.Access-Control-Allow-Origin = req.http.origin;\n }\n{{/ifEq}}\n set resp.http.Access-Control-Allow-Methods = \"{{cors_allowed_methods}}\";\n set resp.http.Vary:Origin = \"\";\n \n }\n",
49+
"template": " if (req.http.Origin && !resp.http.Access-Control-Allow-Origin && !resp.http.Access-Control-Allow-Methods && !resp.http.Access-Control-Allow-Headers) {\n{{#ifEq origin \"anyone\"}}\n set resp.http.Access-Control-Allow-Origin = \"*\";\n{{/ifEq}}\n{{#ifEq origin \"regex-match\"}}\n if ( req.http.Origin ~ \"^https?://{{cors_allowed_origins_regex}}\" ) {\n set resp.http.Access-Control-Allow-Origin = req.http.origin;\n }\n{{/ifEq}}\n set resp.http.Access-Control-Allow-Methods = \"{{cors_allowed_methods}}\";\n{{#if cors_allowed_headers}}\n set resp.http.Access-Control-Allow-Headers = \"{{cors_allowed_headers}}\";\n{{/if}}\n set resp.http.Vary:Origin = \"\";\n \n }\n",
4350
"type": "deliver"
4451
}
4552
],

0 commit comments

Comments
 (0)