在安装好nginx后打开nginx的配置文件.或者打开指定vhost的配置文件.如果不知道文件位置的话可以使用:nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
那么打开配置文件vim /usr/local/etc/nginx/nginx.conf
添加underscores_in_headers on;
`add_header Access-Control-Allow-Origin $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' '*';
add_header Access-Control-Allow-Headers 'XMLHttpRequest, X_FILENAME, accept-encoding, authorization, content-type, dnt, origin, appid, user-agent, x-csrftoken, x-requested-with, cache-control, from, postman-token, x-http-appid, x-http-device, Pragma, farmorg, orgcode,token,app-id,app_id';`
保存退出后重启nginx即可.