You are here

cors_headers.html.twig in Fastly 8.3

if (req.http.Origin && !resp.http.Access-Control-Allow-Origin && !resp.http.Access-Control-Allow-Methods) {
{% if origin == "anyone" %}
  set resp.http.Access-Control-Allow-Origin = "*";
{% elseif origin == "regex-match" %}
  if ( req.http.Origin ~ "^https?://{{ cors_allowed_origins_regex }}" ) {
    set resp.http.Access-Control-Allow-Origin = req.http.origin;
  }
{% endif %}
  set resp.http.Access-Control-Allow-Methods = "{{ cors_allowed_methods }}";
}

File

fastly_edge_modules/templates/cors_headers.html.twig
View source
  1. if (req.http.Origin && !resp.http.Access-Control-Allow-Origin && !resp.http.Access-Control-Allow-Methods) {
  2. {% if origin == "anyone" %}
  3. set resp.http.Access-Control-Allow-Origin = "*";
  4. {% elseif origin == "regex-match" %}
  5. if ( req.http.Origin ~ "^https?://{{ cors_allowed_origins_regex }}" ) {
  6. set resp.http.Access-Control-Allow-Origin = req.http.origin;
  7. }
  8. {% endif %}
  9. set resp.http.Access-Control-Allow-Methods = "{{ cors_allowed_methods }}";
  10. }