arco-design / arco-design-pro-vue

An out-of-the-box solution to quickly build enterprise-level applications based on Arco Design.
https://pro.arco.design
MIT License
1.34k stars 275 forks source link

npm run build部署后登录请求405错误 #154

Closed AlienegraGeek closed 2 years ago

AlienegraGeek commented 2 years ago

基本信息

复现步骤

本地npm run dev测试请求和接口都没有问题,修改对应的VITE_API_BASE_URL服务url之后,npm run build打包dist部署到服务器,登录界面提示请求405错误,请问是我缺少哪些配置吗? nginx config 配置如下 image

生产环境如下 image

sHow8e commented 2 years ago

@AlienegraGeek hi 。如果你只想单纯打包部署看看。那你就要把https://github.com/arco-design/arco-design-pro-vue/blob/1cdd29a8f731bc86303fa0c32f25626eab103ab5/arco-design-pro-vite/src/utils/setup-mock.ts#L4 这部分给修改一下。否则mock在生成环境不会生效。如果你有自己的接口,你就要在nginx做一层proxy,代理到自己接口所在的地址。

AlienegraGeek commented 2 years ago

@AlienegraGeek hi 。如果你只想单纯打包部署看看。那你就要把

https://github.com/arco-design/arco-design-pro-vue/blob/1cdd29a8f731bc86303fa0c32f25626eab103ab5/arco-design-pro-vite/src/utils/setup-mock.ts#L4

这部分给修改一下。否则mock在生成环境不会生效。如果你有自己的接口,你就要在nginx做一层proxy,代理到自己接口所在的地址。

好的,感谢,已经解决了,我发现是由于.env.production内没有定义VITE_API_BASE_URL,我定义之后,再将.env.development中的VITE_API_BASE_URL去掉,就可以调通自己的接口了