fix(admin-client): add x-admin-id header for super admin API requests

- Add x-admin-id header to API interceptor from auth store
- Required for super admin tenant management APIs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-26 08:53:40 -08:00
parent dcff831e7d
commit 7f03a4d870
1 changed files with 15 additions and 1 deletions

View File

@ -8,13 +8,27 @@ const api = axios.create({
},
});
// 请求拦截器 - 添加Token
// 请求拦截器 - 添加Token和Admin ID
api.interceptors.request.use(
(config) => {
const token = localStorage.getItem('admin_token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
// Add x-admin-id header for super admin APIs
const authStorage = localStorage.getItem('auth-storage');
if (authStorage) {
try {
const authData = JSON.parse(authStorage);
if (authData.state?.admin?.id) {
config.headers['x-admin-id'] = authData.state.admin.id;
}
} catch (e) {
// Ignore JSON parse errors
}
}
return config;
},
(error) => {