✨ feat(src/stores/auth.store.ts): обновляет логику получения пользователя после входа и регистрации
✨ feat(src/components/layout/TauriTitlebar.vue): изменяет название приложения с "Daiting" на "Dating" ✨ feat(src/components/layout/SideNav.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(README.md): исправляет название приложения с "Daiting" на "Dating" ✨ fix(src/api/client.ts): обновляет базовый URL API с 'localhost:3000' на 'localhost:1337' ✨ fix(src/views/auth/LoginView.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(src/views/auth/RegisterView.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(src-tauri/Cargo.toml): исправляет описание приложения с "Daiting" на "Dating" ✨ fix(src-tauri/tauri.conf.json): изменяет имя продукта с "Daiting" на "Dating" ✨ fix(vite.config.ts): обновляет порт разработки с 1420 на 3000 ✨ fix(index.html): изменяет заголовок страницы с "Daiting" на "Dating" ✨ fix(dating-app-frontend-prompt.md): исправляет название приложения с "Daiting" на "Dating" ✨ fix(PRODUCT.md): изменяет название приложения с "Daiting" на "Dating"
This commit is contained in:
@@ -2,7 +2,7 @@ import axios from 'axios';
|
||||
import type { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
|
||||
import { Api, HttpClient } from './api';
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3000';
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:1337';
|
||||
|
||||
// ─── Raw axios instance with interceptors ────────────────────────────────────
|
||||
|
||||
@@ -36,7 +36,12 @@ function _processQueue(error: unknown, token: string | null) {
|
||||
}
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => response,
|
||||
(response) => {
|
||||
if (response.data !== null && typeof response.data === 'object' && 'data' in response.data) {
|
||||
response.data = response.data.data;
|
||||
}
|
||||
return response;
|
||||
},
|
||||
async (error) => {
|
||||
const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean };
|
||||
|
||||
@@ -62,11 +67,11 @@ axiosInstance.interceptors.response.use(
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await axios.post<{ accessToken: string; refreshToken: string }>(
|
||||
const res = await axios.post<{ data: { accessToken: string; refreshToken: string } }>(
|
||||
`${BASE_URL}/api/v1/auth/refresh`,
|
||||
{ refreshToken },
|
||||
);
|
||||
const { accessToken, refreshToken: newRefresh } = res.data;
|
||||
const { accessToken, refreshToken: newRefresh } = res.data.data;
|
||||
_setAccessToken(accessToken);
|
||||
localStorage.setItem('refreshToken', newRefresh);
|
||||
_processQueue(null, accessToken);
|
||||
|
||||
Reference in New Issue
Block a user