Cloudflare Pages (docs)
This site is a Next.js static export on Cloudflare Pages, served at https://docs.drive.com.au/drive-apig/* by a shared router Worker in drive-docs.
Architecture
flowchart LR GH[caradvice/drive-apig<br/>develop] -->|push| CFP[CF Pages build] CFP -->|next build + basePath shuffle| OUT[out/drive-apig/*] OUT --> ROUTER[drive-docs router Worker] USER[docs.drive.com.au/drive-apig/] --> ROUTER ROUTER --> OUT
docs/site/ is a standalone package (own package.json, yarn.lock, .yarnrc.yml) — not part of the apig yarn workspaces. Keeps Next 15/React 19 deps isolated; avoids pulling the whole monorepo into the CF build.
Terraform
platform/terraform/env-docs/main.cf-pages.tf:
- Project:
drive-apig-docs, production branchdevelop, GitHub app oncaradvice/drive-apig. - Build: install + build inside
docs/site, then move the export into adrive-apig/subdir forDOCS_BASE_PATH=/drive-apig: - Env vars:
NODE_VERSION=22.22.0,DOCS_BASE_PATH=/drive-apig,DOCS_SITE_URL=https://docs.drive.com.au,GH_REGISTRY_TOKEN(SSM).
Separate stack from env-dev/staging/prod (those pin Cloudflare provider 3.x, which lacks cloudflare_pages_project).
basePath
Next.js basePath rewrites emitted hrefs but not filesystem layout. The build shuffle moves the flat export into drive-apig/ so absolute asset paths resolve on CF Pages. _redirects sends the pages.dev preview root to /drive-apig/.
Manual prerequisites (one-time)
Documented in main.cf-pages.tf header comment, not automated:
- Install CF Pages GitHub app on
caradvice/drive-apig. - Create CF API token (Pages: Edit + Zone DNS/Read on
drive.com.au). - Store in SSM:
/shared/drive/ext/cloudflare/apig/api_token. - Create TFC workspace
drive-apig-docs(orgdrive-apig). - Add
drive-apigtoallowed_reposindrive-docs/platform/terraform/env-shared.
Access gating
docs.drive.com.au/drive-apig/* and drive-apig-docs.pages.dev/* gated by Cloudflare Zero Trust apps owned by drive-docs/platform/terraform/env-shared.
Local dev
cd docs/site
GH_REGISTRY_TOKEN="${GH_REGISTRY_TOKEN:-dummy}" yarn install
yarn dev # http://localhost:3210 (no basePath)
yarn build # static export to docs/site/out/
yarn preview # serve the built out/ dir