赞
踩
- proxy: {
- '/api': {
- target: 'xxxx', //目标url
- changeOrigin: true, //支持跨域
- rewrite: (path) => path.replace(/^\/api/, ''),
- //重写路径,替换/api
- },
- '/plant': {
- target: 'xxxx', //目标url
- changeOrigin: true, //支持跨域
- rewrite: (path) => path.replace(/^\/plant/, ''),
- },
- },
开发环境
- # base api
- VITE_BASE_API = ''
- import request from '@/utils/http'
-
- export function fetchList(query) {
- return request({
-
- // /plant是跨域的前名
- url: '/plant/xxx',
- method: 'get',
- params: query,
- })
- }
axios的基地址
- const service = axios.create({
- baseURL: import.meta.env.VITE_BASE_API, // 设置axios请求的基础的基础地址
- timeout: 30000, // 定义5秒超时
- withCredentials: true,
- })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。