赞
踩
在vite.config.js 中加入以下
- server: {
- proxy: {
- "/api": {
- target: "http://192.168.43.40:8080/", //跨域地址
- changeOrigin: true, //支持跨域
- rewrite: (path) => path.replace(/^\/api/, ""), //重写路径,替换/api
- },
- },
- },
添加一个vite.config.js 文件
- module.exports = {
- // 处理跨域
- devServer: {
- proxy: {
- "/api": {
- target: "https://www.baidu.com/", // 跨域的地址
- changeOrigin: true, // 是否处理跨域
- pathRewrite: {
- "^/api": "", // 重写路径
- },
- },
- },
- },
- };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。