Skip to content

Commit 2899c43

Browse files
dorlugasigalCopilot
andcommitted
fix(site): auto-detect Cloudflare Pages build target
Cloudflare Pages' Git integration was building the site with the GitHub Pages base path '/TermBeam', causing every internal link on termbeam.pages.dev to 404 (and Cloudflare to fall back to a redirect to the github.io copy). astro.config.mjs now auto-detects CF builds via the CF_PAGES=1 env var that Cloudflare sets during builds, switching to base '/' and using CF_PAGES_URL for canonical/OG metadata. GitHub Pages builds remain unchanged. Cloudflare's project just needs: Root directory: packages/site Build command: npm run build Output directory: dist Removes the redundant GH Actions Cloudflare workflow now that Cloudflare's own Git integration handles deploys automatically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 397fdcc commit 2899c43

2 files changed

Lines changed: 7 additions & 70 deletions

File tree

.github/workflows/cloudflare-pages.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

packages/site/astro.config.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { defineConfig } from 'astro/config';
33
import starlight from '@astrojs/starlight';
44

55
// Build target is driven by env so the same source can ship to multiple hosts:
6-
// DEPLOY_TARGET=github-pages (default) — base /TermBeam, site dorlugasigal.github.io
7-
// DEPLOY_TARGET=cloudflare — base /, site from SITE_URL or termbeam.dev
8-
const target = process.env.DEPLOY_TARGET || 'github-pages';
9-
const isCF = target === 'cloudflare';
6+
// default: GitHub Pages — base /TermBeam, site dorlugasigal.github.io
7+
// Cloudflare Pages: detected automatically via CF_PAGES=1 (set by Cloudflare's
8+
// Git integration during builds) OR explicitly via DEPLOY_TARGET=cloudflare.
9+
// Base /, site from CF_PAGES_URL (set by Cloudflare) or SITE_URL.
10+
const explicitTarget = process.env.DEPLOY_TARGET;
11+
const isCF = explicitTarget === 'cloudflare' || process.env.CF_PAGES === '1';
1012

1113
const site = isCF
12-
? process.env.SITE_URL || 'https://termbeam.dev'
14+
? process.env.SITE_URL || process.env.CF_PAGES_URL || 'https://termbeam.pages.dev'
1315
: 'https://dorlugasigal.github.io';
1416
const base = isCF ? '/' : '/TermBeam';
1517
const ogImage = `${site.replace(/\/$/, '')}${base === '/' ? '' : base}/og-image.png`;

0 commit comments

Comments
 (0)