1. vite.config.ts或者vite.config.js文件
server: { port: 3001, host: '0.0.0.0', open: true, proxy: { // 代理配置 '/api': { target: 'https://localhost:44342', changeOrigin: true,//允许跨域 secure:false,//解决自签名证书错误 rewrite: (path) => path.replace(/^\/api/, ''), }, }, },
2. axios中的baseURL设置为'/api'即可
标签:跨域,0.0,api,设置,path,config,vite From: https://www.cnblogs.com/gwjieiee/p/17026893.html