Skip to content

feat(website): serve the site from GitHub Pages behind Cloudflare - #34

Merged
prascli merged 2 commits into
mainfrom
feat/pages-static-export
Nov 12, 2026
Merged

prascli merged 2 commits into
mainfrom
feat/pages-static-export

Conversation

@prascli

@prascli prascli commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Option B: Pages serves the export, Cloudflare stays in front. The existing container origin keeps working; this adds a static target without weakening what the origin does.

What changes

  • next.config.ts: PAGES_EXPORT=1 switches output to export and turns off image optimization. The container build (default, output: "standalone") and its headers() are untouched.
  • trailingSlash: true so a static host serves /docs/ from docs/index.html instead of depending on whether it maps /docs to docs.html. Canonical URL, Open Graph URL, nav link and sitemap follow the same shape.
  • robots.ts, sitemap.ts and opengraph-image.tsx declare dynamic = "force-static", which the export requires for route handlers that are already build-time only.
  • .github/workflows/pages.yml: lint and typecheck on the normal config, then the export build with NEXT_PUBLIC_SITE_URL=https://agentdiet.qansa.web.id, a check that out/ really contains index.html, docs/index.html, 404.html, sitemap.xml and robots.txt, then deploy-pages.
  • DEPLOYMENT.md: the hybrid section, with the Cloudflare Transform Rule header values and the rate limiting rule that replaces proxy.ts, plus the DNS and certificate order.

What Pages loses, and where it is replaced

Pages serves no custom headers and runs no middleware, so CSP, HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy and the three token buckets in proxy.ts do not exist on that origin. They are recreated at Cloudflare: one Transform Rule with the same header values, and one rate limiting rule matching MAX_PER_IP = 60 per minute. The free plan allows a single rate limiting rule, so MAX_PER_SUBNET = 300 and the global GLOBAL_RPS = 120 are covered by Cloudflare's automatic DDoS protection instead; that is documented rather than silently dropped.

Verification

$ cd website && npm ci
$ npm run check
  lint ok, typecheck ok, next build ok (standalone, all routes static)
$ PAGES_EXPORT=1 NEXT_PUBLIC_SITE_URL="https://agentdiet.qansa.web.id" npm run build
  Route (app): / /docs /opengraph-image /robots.txt /sitemap.xml /icon.svg
$ ls out/index.html out/docs/index.html out/404.html out/sitemap.xml out/robots.txt
  all present
$ grep -o 'href="/docs[^"]*"' out/index.html | sort -u
  href="/docs/"
  href="/docs/#ci" ... (anchors preserved)
$ grep -o '<link rel="canonical" href="[^"]*"' out/docs/index.html
  https://agentdiet.qansa.web.id/docs/

The export build also prints Proxy (Middleware), which is misleading: a static export does not deploy it, and DEPLOYMENT.md says so explicitly so the next reader does not assume the token buckets are live.

Not in this PR

DNS and the Cloudflare rules need zone access, which this session does not have. The record order is in DEPLOYMENT.md: CNAME to qansaid.github.io proxied off until the certificate exists, then proxied on plus the Transform Rule and the rate limit rule.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with one non-blocking documentation conflict remaining.

Summary

Adds a GitHub Pages build while keeping the container build available.

  • The website can now be published as static files on GitHub Pages.
  • The docs page now uses a folder-style /docs/ address.

Reviews (2) · Last reviewed commit: "docs(website): record why the rate limit..." · Reviewed by Greptile

@github-actions github-actions Bot added documentation Improvements or additions to documentation website Changes under website/, the Next.js landing page and docs page. ci Workflows, templates and repository automation. labels Nov 12, 2026
Comment thread website/DEPLOYMENT.md Resolved
@prascli
prascli merged commit 0db44a1 into main Nov 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Workflows, templates and repository automation. documentation Improvements or additions to documentation website Changes under website/, the Next.js landing page and docs page.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant