fix(auth): align admin refresh token contract with backend cookie and bearer endpoints [FE-009]
This commit is contained in:
1 parent
dab66a2dce
commit
1c38b95fb0
1 file changed
+18
-5
@@ -87,11 +87,24 @@ api.interceptors.response.use(
|
||||
isRefreshing = true;
|
||||
|
||||
try {
|
||||
const refreshResponse = await axios.post<ApiResponse<AuthResponseData>>(
|
||||
`${baseURL}/auth/refresh`,
|
||||
{},
|
||||
{ withCredentials: true }
|
||||
);
|
||||
let refreshResponse;
|
||||
try {
|
||||
refreshResponse = await axios.post<ApiResponse<AuthResponseData>>(
|
||||
`${baseURL}/auth/refresh`,
|
||||
{},
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: currentToken ? { Authorization: `Bearer ${currentToken}` } : {}
|
||||
}
|
||||
);
|
||||
} catch {
|
||||
// If bearer-based refresh fails (e.g. access token fully expired), try cookie-based /auth/refresh-token
|
||||
refreshResponse = await axios.post<ApiResponse<AuthResponseData>>(
|
||||
`${baseURL}/auth/refresh-token`,
|
||||
{},
|
||||
{ withCredentials: true }
|
||||
);
|
||||
}
|
||||
|
||||
if (refreshResponse.data?.success && refreshResponse.data.data?.accessToken) {
|
||||
const newToken = refreshResponse.data.data.accessToken;
|
||||
|
||||
Reference in new issue
Block a user