Repository navigation
feat(website): serve the site from GitHub Pages behind Cloudflare - #34
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=1switchesoutputtoexportand turns off image optimization. The container build (default,output: "standalone") and itsheaders()are untouched.trailingSlash: trueso a static host serves/docs/fromdocs/index.htmlinstead of depending on whether it maps/docstodocs.html. Canonical URL, Open Graph URL, nav link and sitemap follow the same shape.robots.ts,sitemap.tsandopengraph-image.tsxdeclaredynamic = "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 withNEXT_PUBLIC_SITE_URL=https://agentdiet.qansa.web.id, a check thatout/really containsindex.html,docs/index.html,404.html,sitemap.xmlandrobots.txt, thendeploy-pages.DEPLOYMENT.md: the hybrid section, with the Cloudflare Transform Rule header values and the rate limiting rule that replacesproxy.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.tsdo not exist on that origin. They are recreated at Cloudflare: one Transform Rule with the same header values, and one rate limiting rule matchingMAX_PER_IP = 60per minute. The free plan allows a single rate limiting rule, soMAX_PER_SUBNET = 300and the globalGLOBAL_RPS = 120are covered by Cloudflare's automatic DDoS protection instead; that is documented rather than silently dropped.Verification
The export build also prints
Proxy (Middleware), which is misleading: a static export does not deploy it, andDEPLOYMENT.mdsays 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 toqansaid.github.ioproxied off until the certificate exists, then proxied on plus the Transform Rule and the rate limit rule.

Confidence 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.
/docs/address.Reviews (2) · Last reviewed commit: "docs(website): record why the rate limit..." · Reviewed by Greptile