From be8da44023dbe4d6eb9b750ac39ed477152853db Mon Sep 17 00:00:00 2001 From: Daniil Gaponov Date: Sun, 6 Sep 2026 12:54:17 +0300 Subject: [PATCH] fix(components): return 404 for unknown component libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /components/ rendered an empty shell with HTTP 200, so an unlimited number of non-existent URLs were indexable soft 404s. Other bad paths behaved correctly: / and /components/uikit/ already returned 404. Guard getServerSideProps with a lookup against `libs`, mirroring the existing check in src/pages/design/[sectionId]/index.tsx, where this pattern was already applied. Scope is limited to the soft-404 surface. /components and /components/uikit still render a client-redirect stub; giving them real content is tracked separately, so they are deliberately not turned into redirects here. Verified in dev and in a production build: unknown libs return the real 404 page in en/ru/es, valid library, component, design and landing pages still return 200, and a scan of all 160 sitemap URLs shows no new failures. Build, lint and typecheck pass. E2E not run — Playwright browsers are not installed locally. Co-Authored-By: Claude Opus 5 (1M context) --- src/pages/components/[libId]/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pages/components/[libId]/index.tsx b/src/pages/components/[libId]/index.tsx index 8ce46de18d89..f466930dd14e 100644 --- a/src/pages/components/[libId]/index.tsx +++ b/src/pages/components/[libId]/index.tsx @@ -7,8 +7,21 @@ import {libs} from '../../../content/components'; import {getI18nProps} from '../../../utils'; export const getServerSideProps: GetServerSideProps = async (ctx) => { + const libId = ctx.params?.libId as string; + + // Without this check any /components/ renders an empty shell with HTTP 200, + // so unlimited non-existent URLs are indexable as soft 404s. Mirrors the guard in + // src/pages/design/[sectionId]/index.tsx. + const lib = libs.find((item) => item.id === libId); + + if (!lib) { + return { + notFound: true, + }; + } + return { - props: {libId: ctx.params?.libId, ...(await getI18nProps(ctx))}, + props: {libId, ...(await getI18nProps(ctx))}, }; };