Files
quyun-v2/frontend/user/src/api.ts
2025-12-17 11:48:53 +08:00

20 lines
464 B
TypeScript

import axios from 'axios'
import { getApiBaseURL } from './tenant'
import { toFriendlyApiError } from '@shared/apiError'
export const api = axios.create({
baseURL: getApiBaseURL(),
withCredentials: true,
})
api.interceptors.response.use(
(resp) => resp,
(err) => {
const fe = toFriendlyApiError(err)
const wrapped = new Error(fe.detail || fe.summary)
;(wrapped as any).friendly = fe
;(wrapped as any).cause = err
throw wrapped
},
)