nginx配置允許跨域
在代理配置的位置添加允許跨域代碼:
示例:
location /Tileset/ { root Tileset; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; # 如果有自定義head,需要添加在此處 if ($request_method = 'OPTIONS') { return 204; } }
鑽研不易,轉載請注明出處......