server {
...
add_header Access-Control-Allow-Origin ${http_origin}; # 允许所有来源请求
add_header Access-Control-Allow-Methods *; # 允许所有方法跨域
add_header Access-Control-Allow-Headers ${http_access_control_request_headers}; # 允许所有header跨域
if ($request_method = 'OPTIONS') {
return 200; # 允许OPTIONS请求
}
...