Files
ipal-kit/reference/next.config.ts
T
Radosław SmolińskiandClaude Opus 5.5 804a09efed Project starter: ipal-kit create <domain> generates a new site from the reference site
- bin `ipal-kit` (subcommand `create`): the architecture questions (or --answers JSON),
  rendering from reference/ through starter.manifest.json (placeholders, @starter:if variants,
  //: alternatives, demo dropped), answers into AGENTS.md "Project decisions" and ipal-doctor.json,
  local .env with a fresh PAYLOAD_SECRET, install from the shipped lockfile, ipal-skills,
  ipal-tokens, generate:types/importmap, typecheck, ipal-doctor when shipped, secret check,
  first commit
- @intecion/ipal-kit/starter: the building blocks (renderSite, validateAnswers, applyVariants,
  collectBundle, lockfileWithoutPlugin, secretFindings …)
- build:starter packs reference/ into dist/starter/template.json.gz (90 KB);
  starter:gate in prepublishOnly: site from the packed tarball, frozen install, seed, build,
  targeted SEED_ONLY seed in production mode, full seed refused, pnpm start checks
- D15: plugin dependencies pinned exactly (nodemailer 10.3.1)
- reference/: @starter:if markers (runs as before), manifest generate/variants/rewrite
- docs: project-starter.md, AGENT.md, ipal-setup, ipal-site, ipal-reference (+ api.md),
  README, PROGRAMISTA §2, CHANGELOG, docs/README, reference index

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 15:50:44 +01:00

62 lines
2.3 KiB
TypeScript

import type { NextConfig } from 'next'
import {
buildAdminCspHeaders,
buildImagesConfig,
buildSecurityHeaders,
buildUploadSecurityHeaders,
withSecurityConfig,
} from '@intecion/ipal-kit'
import { withPayload } from '@payloadcms/next/withPayload'
// @starter:if enforceCsp
// CSP enforced: the reference site is the example after the report-only phase (security.md → "ROLL OUT CSP").
const csp = { mode: 'enforce', r2Url: process.env.R2_PUBLIC_URL, reportUri: '/api/csp-report' } as const
// @starter:else
//: // CSP step 1: report-only. Read the [csp] lines in the logs, add a flag or `extra` per report, then switch to
//: // mode: 'enforce' (security.md → "ROLL OUT CSP"; ipal-doctor.json silences the report-only finding until then).
//: const csp = { mode: 'report-only', r2Url: process.env.R2_PUBLIC_URL, reportUri: '/api/csp-report' } as const
// @starter:endif
// Flags = what the site loads: Turnstile on forms, the analytics tools whose IDs are set in Site integrations.
const securityHeaders = buildSecurityHeaders({
csp: {
...csp,
// @starter:if analytics
analytics: true,
// @starter:endif
// @starter:if metaPixel
//: metaPixel: true,
// @starter:endif
// @starter:if linkedIn
//: linkedIn: true,
// @starter:endif
// @starter:if tiktok
//: tiktok: true,
// @starter:endif
// @starter:if clarity
//: clarity: true,
// @starter:endif
turnstile: true,
},
hsts: process.env.NODE_ENV === 'production',
})
const nextConfig: NextConfig = {
// ALLOW_LOCAL_MEDIA=1 (local / CI production checks only): let next/image optimize files the app serves on localhost
images: buildImagesConfig(process.env.ALLOW_LOCAL_MEDIA === '1' ? { production: false } : {}),
// Metadata in <head> for crawlers (deployment.md §3a)
htmlLimitedBots:
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
async headers() {
return [
{ source: '/:path*', headers: securityHeaders },
{ source: '/admin/:path*', headers: buildAdminCspHeaders(csp) }, // after the site-wide rule
...buildUploadSecurityHeaders(),
]
},
}
// withSecurityConfig: no X-Powered-By (Next's and Payload's)
export default withPayload(withSecurityConfig(nextConfig))