JessieExcel/src/utils/http.ts
2026-03-25 01:54:12 +08:00

23 lines
411 B
TypeScript

import axios from 'axios'
export interface ApiEnvelope<T> {
success: boolean
data?: T
error?: string
}
export const http = axios.create({
baseURL: '/api',
timeout: 15000,
})
http.interceptors.request.use((config) => {
const token = localStorage.getItem('token')
if (token) {
config.headers = config.headers ?? {}
config.headers.Authorization = `Bearer ${token}`
}
return config
})