在server段中添加紅框內的圖片跨域內容
參數
location ~* .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
if ($request_method = 'OPTIONS') {
return 204;
}
expires 30d;
}
拓展
這種的就是圖片文件都支持跨域,將要跨域的在location匹配就行。