fix(api-doc): invalid headers

This commit is contained in:
chenos 2024-01-12 09:14:27 +08:00
parent 1871fdd895
commit 57a2bac72a

View File

@ -12,13 +12,13 @@ const Documentation = () => {
const apiClient = useAPIClient();
const { t } = useTranslation();
const swaggerUIRef = useRef();
const { data: urls } = useRequest<{ data: { name: string; url: string }[] }>({ url: 'swagger:getUrls' });
const requestInterceptor = (req) => {
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';
if (match?.[1]) {
req.headers['X-App'] = match?.[1];
}
req.headers['Authorization'] = `Bearer ${apiClient.auth.getToken()}`;
}
return req;