主要看nginx 配置 解決的問題:同源策略引起的跨域問題
server{
listen 8888;#預設埠是80,如果埠沒被佔用可以不用修改
server_name www.xx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
root /var/www/xx/dist;#vue專案的打包後的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否則會出現vue的路由在nginx中重新整理出現404
index index.html index.htm;
}
location /sa {
alias /var/www/test/website/nadclinic/sa;
index index.html;
try_files $uri $uri/ /sa/index.html;
if ( !-e $request_filename) {
rewrite ^ /sa/index.html last;
}
}
location @router {
rewrite ^.*$ /index.html last;
}
location /api/ {
rewrite ^/b/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8082;
}
}
https://blog.csdn.net/weixin_44093204/arti...
本作品採用《CC 協議》,轉載必須註明作者和本文連結