Plate № 04 · Deployment mechanics

A pattern from the gf.cx specimen book

BASE_URL · one-line swap

Source · Dan, 2026-05-28

"Codified after the found.gf.cxio.gf.cx/found migration required sed across four external files to clean up hardcoded preview URLs. The next subdomain starts correct rather than getting fixed at swap time."

The problem

A subdomain spins up on a Pages preview URL (foo-gf-cx.pages.dev) and its custom domain (foo.gf.cx) binds days later. In between, Worker code, tag-previews, OG images, analytics, README copy — every surface composing an absolute URL — references the wrong place. Hand-find-replace at swap time always misses one.

The shape

Export one canonical BASE_URL constant from one shared module. Every other surface imports it. Binding day = one-line edit + redeploy flips everything.

// src/config.ts
export const BASE_URL = "https://foo.gf.cx";

// everywhere else:
import { BASE_URL } from "./config";
const previewUrl = `${BASE_URL}/preview/${id}`;

When it breaks

Reusable elements

The named, copyable pieces — lift any one without the others:

Reference

Source
Dan, 2026-05-28 · codified from the found.gf.cxio.gf.cx/found migration, where retroactive sed across four files was the painful path that motivated this pattern.
In use / example
svc.gf.cx — the service-record routing Worker exports BASE_URL = "https://svc.gf.cx" from src/index.ts with an inline comment naming the one-line swap contract; every self-referencing absolute URL in the Worker imports from that single export.
Reusable elements
Single BASE_URL export · one-line swap on bind day · preview-vs-prod constant convention (listed above).
Origin
found.gf.cxio.gf.cx/found subdomain migration, 2026-05-28 — the four-file sed cleanup that made the pain concrete.
Build cost
~5 min to wire into a new scaffold; zero ongoing overhead. The return is felt at every domain-bind after that.