nginx ajax post跨域请求无法获取formdata数据
同一项目,前后端分离,为防止浏览器跨域使用nginx,配置同样ip端口,通过location匹配到不同的实际项目,做到不跨域访问。
-------nginx-------
server {
listen 80;
server_name 192.168.1.20;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ~* /api/{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For &proxy_add_x_forwarded_for;
proxy_pass http://192.168.1.93:8080;
}
location ~* /apicore/{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For &proxy_add_x_forwarded_for;
proxy_pass http://192.168.11.93:8888;
}
}
-------end---------
这样配置,跨域问题解决,但是:
192.168.1.20/api项目中ajax post请求192.168.1.20/apicore的时候,参数无法获取,get请求没有问题。
api项目中 192.168.1.20/ajax post请求192.168.1.20/api项目的时候,post,get请求都能获取参数内容。
如果要获取post的参数,请问nginx还需要怎么配。!! 求大佬指导。