Fixed notfound headers, r2storage
This commit is contained in:
+5
-2
@@ -150,8 +150,11 @@ Bez skrótów (`HeroSection`, nie `HeroSec`). Nie twórz `lib/pages.ts`,
|
||||
dynamiczna → metadata w body.
|
||||
5. **`htmlLimitedBots`** w `next.config.ts` (seo.md).
|
||||
6. **Nie czytaj `searchParams`** w stronie bez paginacji — deoptymalizuje
|
||||
ISR/SSG. Nie czytaj `headers()` w komponentach bloków (to samo). Locale do
|
||||
bloków wstrzykuj przez `enhanceProps`.
|
||||
ISR/SSG. **Nie czytaj `headers()` / `cookies()`** nigdzie w drzewie stron
|
||||
statycznych — w blokach, komponentach, layoucie `[locale]` ani w
|
||||
`not-found.tsx` (Next 16: `Page changed from static to dynamic at runtime`).
|
||||
Locale do bloków → `enhanceProps`; w `not-found.tsx` (brak `params`) →
|
||||
wersja na każdy język + `<LocaleView>` (pages.md).
|
||||
7. **`export const dynamic = 'force-dynamic'`** na trasach czytających bazę:
|
||||
`manifest.ts`, `sitemap.ts`/`sitemap.xml`, `llms.txt`, `api/health`. Handlery
|
||||
pluginu mają try/catch, ale `dynamic` musi być w pliku trasy.
|
||||
|
||||
@@ -69,9 +69,12 @@ for r in src/app/sitemap.ts src/app/manifest.ts src/app/llms.txt/route.ts src/ap
|
||||
report ERROR "DB route without force-dynamic" "§4.7 build without DB will crash" "$r"
|
||||
done
|
||||
|
||||
report ERROR "headers() in blocks/components" "§4.6 forces dynamic rendering — pass locale via enhanceProps" \
|
||||
report ERROR "headers()/cookies() in blocks/components" "§4.6 forces dynamic rendering — pass locale via enhanceProps" \
|
||||
"$( [ -n "$UI" ] && g "from 'next/headers'" $UI)"
|
||||
|
||||
report ERROR "headers()/cookies() in static page tree" "§4.6 SSG/ISR → 'Page changed from static to dynamic' — not-found: LocaleView (pages.md)" \
|
||||
"$(g "from 'next/headers'" src/app --include=page.tsx --include=layout.tsx --include=not-found.tsx --include=template.tsx | grep -v '/api/\|(payload)')"
|
||||
|
||||
# --- Hardcoding & types (§2, §8) ---
|
||||
report ERROR "hardcoded locale map / any / ts-ignore" "§2, §8" \
|
||||
"$(g 'localizedRoutes|as any\b|@ts-ignore|: any\b' src --include=*.ts --include=*.tsx | grep -v '/payload-types.ts:')"
|
||||
|
||||
@@ -27,7 +27,7 @@ poniżej i doczytaj po `pnpm add`). Reguły: `docs/agent/AGENT.md`.
|
||||
Impeccable albo załóż neutralne tokeny), `@source` na plugin (AGENT.md §6.11).
|
||||
6. **Routing** — `proxy.ts` (`createProxy`), `lib/content.ts`, layout bez
|
||||
`<head>`, catch-all z ISR + `generateStaticParams` + `resolveRedirect`,
|
||||
`not-found.tsx` (PROGRAMISTA §2.6–2.8).
|
||||
`not-found.tsx` z `LocaleView` — bez `headers()`, wersja na każdy język (PROGRAMISTA §2.6–2.8, pages.md).
|
||||
7. **SEO i bezpieczeństwo** — sitemap, robots, manifest, llms.txt, health
|
||||
(wszystkie z `force-dynamic`), `htmlLimitedBots`, `buildSecurityHeaders`,
|
||||
`instrumentation.ts` z `assertEnv` (PROGRAMISTA §2.8–2.9).
|
||||
|
||||
@@ -168,6 +168,8 @@ export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||
export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] }
|
||||
```
|
||||
Ustawia `x-locale` / `x-pathname`, cookie języka za zgodą, przekierowuje `/`.
|
||||
Nagłówki są dla tras dynamicznych (API, route handlery) — w stronach SSG/ISR,
|
||||
layoutach i `not-found.tsx` **nie czytaj `headers()`** (AGENT.md §4.6).
|
||||
|
||||
### 2.7 Warstwa danych — jedno źródło
|
||||
```ts
|
||||
|
||||
-1223
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -141,7 +141,7 @@ Zrób zgodnie z PROGRAMISTA.md §2.6–2.8 i AGENT.md §4:
|
||||
ConsentProvider + CookieBanner + CookieButton + Analytics wewnątrz providera,
|
||||
- [locale]/[[...slug]]/page.tsx: revalidate, generateStaticParams, BEZ searchParams,
|
||||
resolveRedirect przed notFound, enhanceProps wstrzykuje locale do bloków,
|
||||
- [locale]/not-found.tsx z getNotFoundPage (pages.md).
|
||||
- [locale]/not-found.tsx z getNotFoundPage dla każdego języka + LocaleView, BEZ headers() (pages.md).
|
||||
Plan najpierw.
|
||||
```
|
||||
Sprawdź: `/` → `/<domyślny język>`; `pnpm build` pokazuje strony jako `●`;
|
||||
|
||||
+24
-10
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user