Skip to content

refactor: move reflinks into env-configurable DEFAULT_REFLINKS#2

Open
rtunazzz wants to merge 1 commit into
mainfrom
claude/reflinks-env-config-DGk6j
Open

refactor: move reflinks into env-configurable DEFAULT_REFLINKS#2
rtunazzz wants to merge 1 commit into
mainfrom
claude/reflinks-env-config-DGk6j

Conversation

@rtunazzz
Copy link
Copy Markdown
Owner

@rtunazzz rtunazzz commented Apr 9, 2026

Consolidate every hardcoded referral slug into a single DEFAULT_REFLINKS
constant at the top of static/redirect-data.js and parameterize all
reflink-bearing buildUrl closures on a new ref argument. The worker
builds the reflinks config at request time from env vars (REF for the
default slug, REF_ for per-platform overrides, with underscores
mapped to hyphens), falling back to DEFAULT_REFLINKS when nothing is set
so existing deployments are byte-identical without any env var setup.

Since the service worker can't read Cloudflare env, worker.js intercepts
/static/redirect-data.js and appends self.REFLINKS = {...} (with
Cache-Control: no-store so env changes propagate without a redeploy);
sw.js reads self.REFLINKS and passes it through to buildRedirectUrl.
Forkers can now customize their reflinks entirely from the Pages
dashboard — no code changes required.

Consolidate every hardcoded referral slug into a single DEFAULT_REFLINKS
constant at the top of static/redirect-data.js and parameterize all
reflink-bearing buildUrl closures on a new `ref` argument. The worker
builds the reflinks config at request time from env vars (REF for the
default slug, REF_<PLATFORM> for per-platform overrides, with underscores
mapped to hyphens), falling back to DEFAULT_REFLINKS when nothing is set
so existing deployments are byte-identical without any env var setup.

Since the service worker can't read Cloudflare env, worker.js intercepts
/static/redirect-data.js and appends `self.REFLINKS = {...}` (with
Cache-Control: no-store so env changes propagate without a redeploy);
sw.js reads self.REFLINKS and passes it through to buildRedirectUrl.
Forkers can now customize their reflinks entirely from the Pages
dashboard — no code changes required.
@rtunazzz rtunazzz force-pushed the claude/reflinks-env-config-DGk6j branch from 0d8a25d to 8a33933 Compare April 13, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants