// 项目部署基础 // 默认状况下,咱们假设你的应用将被部署在域的根目录下, // 例如:https://www.my-app.com/ // 默认:'/' // 若是您的应用程序部署在子路径中,则须要在这指定子路径 // 例如:https://www.foobar.com/my-app/ // 须要将它改成'/my-app/' const BASE_URL = process.env.NODE_ENV === 'production' ? '/new/' : '/'
nginx
配置修改,假设作了跨域代理。核心代码以下:html
server { listen 1081; server_name localhost; location ^~/new { alias html/dist-new; #index index.html; try_files $uri $uri/ @rewrites; } location @rewrites { rewrite ^/(new)/(.+)$ /$1/index.html last; } # 设置代理,解决接口跨域问题 location /api { rewrite ^/api(.*)$ /$1 break; proxy_set_header x-forwarded-for $remote_addr; proxy_pass http://127.0.0.1:8105; } }