Answer the question
In order to leave comments, you need to log in
How to add Access-Control-Allow-Origin header only if request came from https://example.org/ domain and request method was GET?
wrote this config, but for some reason header with the correct origin is still not added , you can't
use map
server {
listen 80;
server_name api.85f260ffe1ad0b24ff0ef6b645f46e25.kis.im;
location / {
set $cors '';
set $cors_allowed_methods 'OPTIONS, HEAD, GET';
if ($http_origin="https://example.org/") {
set $cors 'origin_matched';
}
if ($request_method = "GET") {
set $cors '${cors} & preflight';
}
if ($cors = 'origin_matched & preflight') {
add_header Access-Control-Allow-Origin $http_origin always;
}
return 200;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question