28 lines
521 B
TypeScript
28 lines
521 B
TypeScript
import { createFetch } from '@vueuse/core'
|
|
import { API_BASE_URL } from '~/CONSTANT'
|
|
|
|
export const authCode = ref(
|
|
localStorage.getItem('authCode')
|
|
|| sessionStorage.getItem('authCode')
|
|
|| '',
|
|
)
|
|
|
|
export const baseFetch = createFetch({
|
|
baseUrl: API_BASE_URL,
|
|
options: {
|
|
async beforeFetch({ options }) {
|
|
const code = '0101'
|
|
options.headers = {
|
|
...options.headers,
|
|
Authorization: `${code}`,
|
|
}
|
|
return { options }
|
|
},
|
|
|
|
},
|
|
fetchOptions: {
|
|
mode: 'cors',
|
|
},
|
|
|
|
})
|