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:
parent
dcff831e7d
commit
7f03a4d870
|
|
@ -8,13 +8,27 @@ const api = axios.create({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 请求拦截器 - 添加Token
|
// 请求拦截器 - 添加Token和Admin ID
|
||||||
api.interceptors.request.use(
|
api.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
const token = localStorage.getItem('admin_token');
|
const token = localStorage.getItem('admin_token');
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers.Authorization = `Bearer ${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;
|
return config;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue