fix(plugin-api-doc): non-main application crashes (#3100)

This commit is contained in:
Dunqing 2023-11-27 20:42:29 +08:00 committed by GitHub
parent 723cc45d0f
commit 7b66def487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,9 @@ const Documentation = () => {
const { data: urls } = useRequest<{ data: { name: string; url: string }[] }>({ url: 'swagger:getUrls' }); const { data: urls } = useRequest<{ data: { name: string; url: string }[] }>({ url: 'swagger:getUrls' });
const requestInterceptor = (req) => { const requestInterceptor = (req) => {
if (!req.headers['Authorization']) { if (!req.headers['Authorization']) {
const match = location.pathname.match(/^\/apps\/([^/]*)\//);
// multi apps need to set X-App header
req.headers['X-App'] = match?.[1] || 'main';
req.headers['Authorization'] = `Bearer ${apiClient.auth.getToken()}`; req.headers['Authorization'] = `Bearer ${apiClient.auth.getToken()}`;
} }
return req; return req;