docs(vite.config.ts): 📝 反向代理解决跨域注释完善
Former-commit-id: dc1a27b761d1a72fcdf7396793ca7ce2b515f045
This commit is contained in:
@@ -40,17 +40,14 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
port: Number(env.VITE_APP_PORT),
|
port: Number(env.VITE_APP_PORT),
|
||||||
open: true, // 运行是否自动打开浏览器
|
open: true, // 运行是否自动打开浏览器
|
||||||
// 反向代理解决跨域
|
|
||||||
proxy: {
|
proxy: {
|
||||||
|
// 反向代理解决跨域
|
||||||
[env.VITE_APP_BASE_API]: {
|
[env.VITE_APP_BASE_API]: {
|
||||||
// 线上接口API地址
|
target: "http://vapi.youlai.tech", // 线上接口地址
|
||||||
target: "http://vapi.youlai.tech",
|
// target: 'http://localhost:8989', // 本地接口地址 , 后端工程仓库地址:https://gitee.com/youlaiorg/youlai-boot
|
||||||
// 本地接口API地址
|
|
||||||
// target: 'http://localhost:8989',
|
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) =>
|
rewrite: (path) =>
|
||||||
// localhost:3000/dev-api/users/me → http://vapi.youlai.tech/users/me
|
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""), // 替换 /dev-api 为 target 接口地址
|
||||||
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user