From 7b66def4872c82137b914a61b0abd27b692d5d07 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Mon, 27 Nov 2023 20:42:29 +0800 Subject: [PATCH] fix(plugin-api-doc): non-main application crashes (#3100) --- .../plugins/@nocobase/plugin-api-doc/src/client/Document.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/plugins/@nocobase/plugin-api-doc/src/client/Document.tsx b/packages/plugins/@nocobase/plugin-api-doc/src/client/Document.tsx index fbbce4527..c7ee6806f 100644 --- a/packages/plugins/@nocobase/plugin-api-doc/src/client/Document.tsx +++ b/packages/plugins/@nocobase/plugin-api-doc/src/client/Document.tsx @@ -16,6 +16,9 @@ const Documentation = () => { 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'; req.headers['Authorization'] = `Bearer ${apiClient.auth.getToken()}`; } return req;