update
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
import { User as Auth0UserModel } from '@auth0/auth0-spa-js';
|
||||
|
||||
import { getData, setData } from '@/utils';
|
||||
import { type AuthModel } from './_models';
|
||||
// import https from 'https'
|
||||
|
||||
const AUTH_LOCAL_STORAGE_KEY = `${import.meta.env.VITE_APP_NAME}-auth-v${
|
||||
import.meta.env.VITE_APP_VERSION
|
||||
}`;
|
||||
const AUTH_LOCAL_STORAGE_KEY = `${import.meta.env.VITE_APP_NAME}-auth-v${import.meta.env.VITE_APP_VERSION
|
||||
}`;
|
||||
|
||||
const getAuth = (): AuthModel | undefined => {
|
||||
try {
|
||||
@ -40,25 +39,12 @@ const removeAuth = () => {
|
||||
export function setupAxios(axios: any) {
|
||||
axios.defaults.headers.Accept = 'application/json';
|
||||
axios.interceptors.request.use(
|
||||
(config: { headers: { Authorization: string }; params?: any; url?: any }) => {
|
||||
(config: { headers: { Authorization: string }; params?: any; url?: any; httpsAgent: any }) => {
|
||||
const auth = getAuth();
|
||||
|
||||
if (auth?.access_token) {
|
||||
config.headers.Authorization = `Bearer ${auth.access_token}`;
|
||||
|
||||
if (
|
||||
config.url &&
|
||||
!config.url.includes('api/b/') &&
|
||||
!config.url.includes('api/bg/') &&
|
||||
!config.url.includes('api/c/')
|
||||
) {
|
||||
config.params = {
|
||||
...config.params,
|
||||
token: auth.access_token || ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
async (err: any) => await Promise.reject(err)
|
||||
|
||||
Reference in New Issue
Block a user