- 为了解决请求跨域问题,于是配置了代理解决跨域
"devServer": {
"port": 8080, //端口号
"disableHostCheck": true,
"proxy": {
"/api": {
"target": "https://api.book118.com", //目标接口域名
"changeOrigin": true, //是否跨域
"secure": true, // 设置支持https协议的代理
"pathRewrite": {
"^/api": ""
}
}
}
} - 使用vue2打包就是正常的,但是使用VUE3打包就提示需要设置server.fs.allow什么的,又不知道具体怎么设置
18:34:35.998 Unrestricted file system access to "/api/applet/index/getRecommendDocs"
18:34:35.998 For security concerns, accessing files outside of serving allow list will be restricted by default in the future version of Vite. Refer to https://vitejs.dev/config/#server-fs-allow for more details.
uv_UI
- 发布:2021-09-16 18:40
- 更新:2021-11-07 18:28
- 阅读:2705
在 vite.config.js 配置:
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
export default defineConfig({
plugins: [
uni(),
],
server: {
port: 3344,
proxy: {
'/api': {
target: 'http://xxxxxx', // 自己的云服务
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
})
cookUni
好人一生平安
2021-11-11 16:33
4***@qq.com
好像运行到浏览器可以,运行到手机不行?
2023-01-28 10:47