From e4f5c8f710b8169d4ea8ff516de194aba8961050 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:09:14 +0800 Subject: [PATCH] feat: only prefetch for first load --- .../components/plugins/marketplace/hydration-server.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/app/components/plugins/marketplace/hydration-server.tsx b/web/app/components/plugins/marketplace/hydration-server.tsx index 3aabe4d123..c87a846c5c 100644 --- a/web/app/components/plugins/marketplace/hydration-server.tsx +++ b/web/app/components/plugins/marketplace/hydration-server.tsx @@ -1,6 +1,7 @@ import type { SearchParams } from 'nuqs' import type { CreatorSearchParams, PluginsSearchParams, TemplateSearchParams } from './types' import { dehydrate, HydrationBoundary } from '@tanstack/react-query' +import { headers } from 'next/headers' import { createLoader } from 'nuqs/server' import { getQueryClientServer } from '@/context/query-client-server' import { marketplaceQuery } from '@/service/client' @@ -46,10 +47,18 @@ function getNextPageParam(lastPage: { page: number, page_size: number, total: nu type RouteParams = { category?: string, creationType?: string, searchTab?: string } | undefined +async function shouldSkipServerPrefetch() { + const requestHeaders = await headers() + return requestHeaders.get('sec-fetch-dest') !== 'document' +} + async function getDehydratedState( params?: Awaitable, searchParams?: Awaitable, ) { + if (await shouldSkipServerPrefetch()) + return + const rawParams = params ? await params : undefined const rawSearchParams = searchParams ? await searchParams : undefined const parsedSearchParams = await loadSearchParams(Promise.resolve(rawSearchParams ?? {}))