前端后数据分离后,跨域问题肯定存在的。解决办法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 //重新加载配置