使用nginx做静态资源服务器(离线地图),我已经在nginx配置中加了Access-Control-Allow-Origin头部等配置,如下:
# MapSources Server cesium服务
server {
listen 9602;
server_name 192.168.10.26;
location / {
root F://CesiumData;
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';
}
}
部分请求还是会出现跨域的问题。如下图:
解决办法:
来源:https://www.jianshu.com/p/c03d33663cfc
原因该请求的返回码是404,而按照nginx官方文档针