若依系统Vue框架前端部署bug总结

若依系统Vue框架前端部署bug总结

前端都采用 Nginx部署,后端采用jar部署使用nginx实现反向代理,前端打包部署后出现很多问题。

  1. nginx配置
server {
    listen 8080;  # 监听的端口
    server_name localhost;  # 替换为你的域名或 IP 地址
    # 配置前端静态资源
    location /flow{
        alias /usr/flow/front/dist;  # 静态资源路径
        try_files $uri $uri/ /index.html;
        index index.html index.htm;
    }

    # 反向代理后端 API
    location /flow-admin/ {
        proxy_pass http://localhost:8121/;  # 后端服务地址
        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_set_header X-Forwarded-Proto $scheme;
    }
}

2. 前端打包命令

npm run build:prod

3. 前端修改

  • vue.config.js文件:
    在这里插入图片描述
    在这里插入图片描述
  • permision.js文件
    在这里插入图片描述
  • router文件
    在这里插入图片描述
    因为修改了后端访问url因此还需要修改env.production文件中的VUE_APP_BASE_API(使用默认prod-api忽略此步)
# 系统/生产环境
VUE_APP_BASE_API = '/flow-admin'

同时修改退出登录方法,让页面回退到flow

this.$store.dispatch('LogOut').then(() => {
          // 本地
          location.href = '/index';
          // 部署
          // location.href = '/flow';
        })
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值