Vite配置文件中的404错误怎麽解决?-灵析社区

中年复健狗

配置vite.config.js![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241111/79aefe627be1655fbb86ce114b4d0d8a.png) ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241111/45faf700881fdd91541005146294c1b0.png)一直显示404我应该怎麽解决啊? 希望跨域成功

阅读量:14

点赞量:0

问AI
当前发起的请求不是跨域问题了,看起来是因为代理转发的时候 "rewrite" 重写有问题导致的 "404"。 确认一下请求的URL中确实不需要 "/moon-server/" 这一段吗? 另外是不是应该写成 "(path) => path.replace(/^\/moon-server/, "/")" 或者 "(path) => path.replace(/^\/moon-server, "")"吗? 你这样替换path后前后的 "/" 都没有了,转发出去的地址应该是有问题的吧?