uni-app H5 + VUE3 请求无返回值,疑似与vite配置有关
uni-app H5 + VUE3 请求无返回值,疑似与vite配置有关
配置代理解决跨域问题
-
为了解决请求跨域问题,于是配置了代理解决跨域
"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.

更多关于uni-app H5 + VUE3 请求无返回值,疑似与vite配置有关的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在 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/, ‘’),
},
},
},
})
更多关于uni-app H5 + VUE3 请求无返回值,疑似与vite配置有关的实战教程也可以访问 https://www.itying.com/category-93-b0.html
好人一生平安
好像运行到浏览器可以,运行到手机不行?
麻烦知道的给个回复嘛
官方的给个回复呗
vue3的话,先使用vite.config.js配置proxy
https://cn.vitejs.dev/config/#server-proxy
好像运行到浏览器可以,运行到手机不行?


