Created
October 22, 2021 03:20
-
-
Save parrya/0b381781c9139f833dcc8d04cf0d51d5 to your computer and use it in GitHub Desktop.
CORS header code for redirects in layout service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpResponseBase response = filterContext.HttpContext.Response; | |
response.Headers["Access-Control-Allow-Origin"] = header; | |
if (string.IsNullOrWhiteSpace(response.Headers.Get("Access-Control-Allow-Headers"))) | |
response.AddHeader("Access-Control-Allow-Headers", "*"); | |
if (string.IsNullOrWhiteSpace(response.Headers.Get("Access-Control-Allow-Credentials"))) | |
response.AddHeader("Access-Control-Allow-Credentials", "true"); | |
if (string.IsNullOrWhiteSpace(response.Headers.Get("Access-Control-Allow-Credentials"))) | |
response.AddHeader("Access-Control-Expose-Headers", "ETag"); | |
if (!string.IsNullOrWhiteSpace(response.Headers.Get("Access-Control-Max-Age"))) | |
return; | |
response.AddHeader("Access-Control-Max-Age", "10"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment