refactor(web): remove basePath from hydration boundary (#39308)

This commit is contained in:
yyh 2026-07-20 22:46:37 +08:00 committed by GitHub
parent ef0115d340
commit b7193d1cba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -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')

View File

@ -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<ConsoleErrorPa
const getCurrentPath = async () => {
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}`
}