Apply repository-wide ESLint auto-fix formatting pass
Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
@@ -8,15 +8,15 @@
|
||||
* 401 token refresh with request queuing.
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import { getCookie, deleteCookie } from '@/utils/cookieUtil.js';
|
||||
import axios from "axios";
|
||||
import { getCookie, deleteCookie } from "@/utils/cookieUtil.js";
|
||||
|
||||
/** Axios instance configured with auth interceptors. */
|
||||
const apiClient = axios.create();
|
||||
|
||||
// Request interceptor: automatically attach Authorization header
|
||||
apiClient.interceptors.request.use((config) => {
|
||||
const token = getCookie('luciaToken');
|
||||
const token = getCookie("luciaToken");
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ apiClient.interceptors.response.use(
|
||||
if (
|
||||
error.response?.status !== 401 ||
|
||||
originalRequest._retried ||
|
||||
originalRequest.url === '/api/oauth/token'
|
||||
originalRequest.url === "/api/oauth/token"
|
||||
) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ apiClient.interceptors.response.use(
|
||||
|
||||
try {
|
||||
// Dynamic import to avoid circular dependency with login store
|
||||
const { refreshTokenAndGetNew } = await import('@/api/auth.js');
|
||||
const { refreshTokenAndGetNew } = await import("@/api/auth.js");
|
||||
const newToken = await refreshTokenAndGetNew();
|
||||
isRefreshing = false;
|
||||
onRefreshSuccess(newToken);
|
||||
@@ -87,11 +87,11 @@ apiClient.interceptors.response.use(
|
||||
onRefreshFailure(refreshError);
|
||||
|
||||
// Refresh failed: clear auth and redirect to login
|
||||
deleteCookie('luciaToken');
|
||||
window.location.href = '/login';
|
||||
deleteCookie("luciaToken");
|
||||
window.location.href = "/login";
|
||||
return Promise.reject(refreshError);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default apiClient;
|
||||
|
||||
Reference in New Issue
Block a user