location / {
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
return 200;
}
//本地所指向的地址
proxy_pass http://127.0.0.1:7457;
proxy_redirect default;
}
location /api{
rewrite ^/api/(.*)$ /$1 break;
//我们要访问的接口地址
proxy_pass https://dev-api-fillcolor.hudong.city/;
}
网友评论