Fixed notfound headers, r2storage

This commit is contained in:
2026-10-13 15:57:59 +02:00
parent 86c873e4e7
commit 786dd346a9
24 changed files with 1506 additions and 2765 deletions
+24 -10
View File
@@ -62,24 +62,38 @@ Site Settings → System Pages → **404 (Not Found)**. Edytor wybiera:
- stronę główną (część klientów tak woli), **albo**
- nic → projekt pokazuje wbudowany fallback z `not-found.tsx`.
Projekt (`app/(frontend)/[locale]/not-found.tsx`) — gotowy przykład w
Projekt (`app/(frontend)/[locale]/not-found.tsx`) — pełny przykład w
`frontend/[locale]/not-found.tsx`:
```tsx
import { headers } from 'next/headers'
import { getNotFoundPage } from '@/lib/content' // z createContentHelpers
import { RenderBlocks } from '@intecion/ipal-kit/rsc'
import { LocaleView } from '@intecion/ipal-kit/client'
import { getConfiguredLocales, getNotFoundPage } from '@/lib/content'
export default async function NotFound() {
const locale = (await headers()).get('x-locale') ?? i18nConfig.defaultLocale
const page = await getNotFoundPage(locale) // null → fallback
if (page?.layout?.length) return <RenderBlocks blocks={page.layout} components={blockRegistry} />
return <Fallback404 locale={locale} />
const locales = await getConfiguredLocales()
const views = Object.fromEntries(await Promise.all(locales.map(async (locale) => {
const page = await getNotFoundPage(locale) // null → brak przypisania
return [locale, page?.layout?.length
? <RenderBlocks blocks={page.layout} components={blockRegistry} enhanceProps={() => ({ locale })} />
: null]
})))
return <LocaleView views={views} defaultLocale={i18nConfig.defaultLocale} />
}
```
`not-found.tsx` nie dostaje `params` — locale bierzemy z nagłówka `x-locale`,
który ustawia proxy z `createProxy`. Status HTTP zostaje **404** (renderuje go
Next po `notFound()`), treść jest z panelu.
> **NIE czytaj `headers()` w `not-found.tsx`** (`LocaleView` od 1.7.13). `not-found.tsx` nie dostaje
> `params`, ale `headers()` (np. `x-locale` z proxy) zamienia stronę SSG/ISR w
> dynamiczną — Next 16 rzuca `Page changed from static to dynamic at runtime`
> (AGENT.md §4.6). Dlatego serwer renderuje stronę 404 **dla każdego języka**
> (same odczyty z bazy — trasa zostaje statyczna), a `<LocaleView>` (komponent
> kliencki pluginu) wybiera wersję po pierwszym segmencie URL (`usePathname`).
> Działa też przy SSR — HTML ma od razu właściwy język. Layout `[locale]`
> (nagłówek, menu, stopka) i tak dostaje `params.locale` z URL.
Status HTTP zostaje **404** (renderuje go Next po `notFound()`), treść jest z
panelu we właściwym języku. Koszt: w payloadzie RSC strony 404 są wersje dla
wszystkich języków — przy stronie 404 to pomijalne.
Co plugin robi automatycznie z przypisaną stroną 404: