This commit is contained in:
AceDataCloud committed 2023-02-26 01:44:23 +08:00
1 parent e66cb2196b
commit 27b2321053
1 file changed
+4 -2
+4 -2
View File
@@ -1,7 +1,6 @@
import router, { ROUTE_AUTH_LOGIN, ROUTE_INDEX } from '@/router';
import router, { ROUTE_AUTH_LOGIN } from '@/router';
import store from '@/store';
import axios, { AxiosInstance } from 'axios';
import { getCookie } from 'typescript-cookie';
const httpClient: AxiosInstance = axios.create({
baseURL: '/api/v1',
@@ -13,6 +12,9 @@ const httpClient: AxiosInstance = axios.create({
httpClient.interceptors.request.use((config) => {
const accessToken = store.getters.accessToken;
if (!config.headers) {
config.headers = {};
}
if (accessToken) {
config.headers['Authorization'] = `Bearer ${accessToken}`;
}