From b7193d1cba49050ba32f346aee07fc53f1dc5910 Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:46:37 +0800 Subject: [PATCH] refactor(web): remove basePath from hydration boundary (#39308) --- .../(commonLayout)/__tests__/hydration-boundary.spec.tsx | 7 ++++--- web/app/(commonLayout)/hydration-boundary.tsx | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/app/(commonLayout)/__tests__/hydration-boundary.spec.tsx b/web/app/(commonLayout)/__tests__/hydration-boundary.spec.tsx index 82878ebc600..b34faae8248 100644 --- a/web/app/(commonLayout)/__tests__/hydration-boundary.spec.tsx +++ b/web/app/(commonLayout)/__tests__/hydration-boundary.spec.tsx @@ -107,7 +107,7 @@ describe('CommonLayoutHydrationBoundary', () => { }) }) - it('should hydrate common layout queries and render children', async () => { + it('should prefetch common layout queries and render children', async () => { const { CommonLayoutHydrationBoundary } = await import('../hydration-boundary') const element = await CommonLayoutHydrationBoundary({ @@ -147,7 +147,8 @@ describe('CommonLayoutHydrationBoundary', () => { ) }) - it('should default unauthorized refresh redirects to the home path when the pathname header is missing', async () => { + it('should use the internal home path when the pathname header is missing', async () => { + mocks.basePath = '/workflow' mocks.headers.mockResolvedValue(new Headers()) mocks.profileQueryFn.mockRejectedValue( new Response(JSON.stringify({ code: 'unauthorized' }), { status: 401 }), @@ -162,7 +163,7 @@ describe('CommonLayoutHydrationBoundary', () => { it.each([ ['not_setup', '/install'], ['not_init_validated', '/init'], - ])('should use a basePath-relative destination for %s errors', async (code, destination) => { + ])('should use an internal destination for %s errors', async (code, destination) => { mocks.basePath = '/workflow' mocks.profileQueryFn.mockRejectedValue(new Response(JSON.stringify({ code }), { status: 401 })) const { CommonLayoutHydrationBoundary } = await import('../hydration-boundary') diff --git a/web/app/(commonLayout)/hydration-boundary.tsx b/web/app/(commonLayout)/hydration-boundary.tsx index 74f7da57175..dda23f3e43f 100644 --- a/web/app/(commonLayout)/hydration-boundary.tsx +++ b/web/app/(commonLayout)/hydration-boundary.tsx @@ -10,7 +10,6 @@ import { resolveServerConsoleApiUrl, serverConsoleQuery, } from '@/service/server' -import { basePath } from '@/utils/var' const CURRENT_PATHNAME_HEADER = 'x-dify-pathname' const CURRENT_SEARCH_HEADER = 'x-dify-search' @@ -35,7 +34,7 @@ const parseConsoleErrorPayload = async (error: Response): Promise { const requestHeaders = await headers() - const pathname = requestHeaders.get(CURRENT_PATHNAME_HEADER) || `${basePath}/` + const pathname = requestHeaders.get(CURRENT_PATHNAME_HEADER) || '/' const search = requestHeaders.get(CURRENT_SEARCH_HEADER) || '' return `${pathname}${search}` }