feat: 添加vite的proxy代理设置
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export { requestClient } from './requestClient'
|
||||
export type { ApiResponse, RequestErrorEvent, RequestOptions } from './types'
|
||||
export type { ApiResponse, RequestErrorEvent } from './types'
|
||||
|
||||
/** 注册错误 UI 展示(副作用导入,应用启动时执行) */
|
||||
import './errorUI'
|
||||
|
||||
@@ -28,5 +28,16 @@ export default defineConfig({
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
/** 后端服务地址,按需修改 */
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
/** 去掉 /api 前缀转发给后端(如 /api/auth/login → /auth/login) */
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user