feat: update

This commit is contained in:
yanghao05
2025-04-29 20:22:14 +08:00
parent 5dc8431f19
commit 128dc4cdab
2 changed files with 12 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import axios from 'axios';
const client = axios.create({
baseURL: '/v1',
timeout: 10000,
withCredentials: true,
headers: {
'Content-Type': 'application/json',
}
@@ -27,6 +28,12 @@ client.interceptors.response.use(
error => {
// Handle HTTP errors here
if (error.response) {
// Handle 401 Unauthorized error
if (error.response.status === 401) {
const redirectUrl = encodeURIComponent(window.location.href);
window.location.href = `/v1/auth/wechat?redirect=${redirectUrl}`;
return;
}
// Server responded with error status
console.error('API Error:', error.response.status, error.response.data);
} else if (error.request) {