前端后数据分离后,跨域问题肯定存在的。解决办法cors,jsonp解决跨域问题,当然服务端要设置信认。也可以设置成同域,这样跨域问题就不存在了。
# cat dsp.conf //配置
server
{
listen 8080;
server_name 10.0.0.237;
location / {
root /var/www/dsp/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api/ { //接口反代
proxy_pass http://10.0.0.30;
}
access_log /var/log/nginx/dsp.access.log;
error_log /var/log/nginx/dsp.error.log;
}
# nginx -t //检测
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# systemctl reload nginx //重新加载配置
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/jsjquery/2069.html