2017-07-22 15:52:20 +02:00
|
|
|
{% if nginx_cors_extended_rules %}
|
2017-07-21 18:45:34 +02:00
|
|
|
if ($request_method = 'OPTIONS') {
|
2016-11-28 16:45:01 +01:00
|
|
|
{% if nginx_cors_limit_origin %}
|
2017-08-16 18:15:27 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
|
2016-11-28 16:40:45 +01:00
|
|
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
2017-07-21 18:40:03 +02:00
|
|
|
{% else %}
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2017-07-21 18:45:34 +02:00
|
|
|
{% endif %}
|
2018-03-11 14:33:32 +01:00
|
|
|
add_header 'Access-Control-Allow-Methods' '{{ nginx_cors_allowed_methods }}';
|
2017-07-21 18:40:03 +02:00
|
|
|
#
|
|
|
|
# Custom headers and headers various browsers *should* be OK with but aren't
|
|
|
|
#
|
2017-10-25 14:59:14 +02:00
|
|
|
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
2017-07-21 18:40:03 +02:00
|
|
|
#
|
|
|
|
# Tell client that this pre-flight info is valid for 20 days
|
|
|
|
#
|
|
|
|
add_header 'Access-Control-Max-Age' 1728000;
|
|
|
|
add_header 'Content-Type' 'text/plain charset=UTF-8';
|
|
|
|
add_header 'Content-Length' 0;
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
if ($request_method = 'POST') {
|
2017-07-21 18:45:34 +02:00
|
|
|
{% if nginx_cors_limit_origin %}
|
2017-08-16 18:15:27 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
|
2017-07-21 18:45:34 +02:00
|
|
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
|
|
|
{% else %}
|
2017-07-21 18:40:03 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2017-07-21 18:45:34 +02:00
|
|
|
{% endif %}
|
2018-03-11 14:33:32 +01:00
|
|
|
add_header 'Access-Control-Allow-Methods' '{{ nginx_cors_allowed_methods }}';
|
2017-10-25 14:59:14 +02:00
|
|
|
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
|
|
|
add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
2017-07-21 18:40:03 +02:00
|
|
|
}
|
|
|
|
if ($request_method = 'GET') {
|
2017-07-21 18:45:34 +02:00
|
|
|
{% if nginx_cors_limit_origin %}
|
2017-08-16 18:15:27 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
|
2017-07-21 18:45:34 +02:00
|
|
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
|
|
|
{% else %}
|
2017-07-21 18:40:03 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2017-07-21 18:45:34 +02:00
|
|
|
{% endif %}
|
2018-03-11 14:33:32 +01:00
|
|
|
add_header 'Access-Control-Allow-Methods' '{{ nginx_cors_allowed_methods }}';
|
2017-10-25 14:59:14 +02:00
|
|
|
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
|
|
|
add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
2017-07-21 18:40:03 +02:00
|
|
|
}
|
2017-07-22 15:52:20 +02:00
|
|
|
{% else %}
|
|
|
|
{% if nginx_cors_limit_origin %}
|
2017-08-16 15:16:03 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '{{ nginx_cors_acl_origin | default("$http_origin") }}';
|
|
|
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
2017-07-22 15:52:20 +02:00
|
|
|
{% else %}
|
2017-08-16 15:16:03 +02:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2017-07-22 15:52:20 +02:00
|
|
|
{% endif %}
|
2018-03-11 14:33:32 +01:00
|
|
|
add_header 'Access-Control-Allow-Methods' '{{ nginx_cors_allowed_methods }}';
|
2017-10-25 14:59:14 +02:00
|
|
|
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
2018-03-11 14:33:32 +01:00
|
|
|
add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range';
|
2017-07-22 15:52:20 +02:00
|
|
|
{% if nginx_cors_limit_origin %}
|
|
|
|
if ($request_method = 'OPTIONS') {
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
{% endif %}
|
2017-08-16 15:16:03 +02:00
|
|
|
{% endif %}
|
2017-07-22 15:52:20 +02:00
|
|
|
|