Cloudflare Workers
Repo: platform-api-gateway
Location: workers/admin-gateway/, workers/public-gateway/
Two Workers, one per audience domain:
| Worker | External domain | Internal origin |
|---|---|---|
admin-gateway | api-dev.eigenoid.services | api-admin-internal-dev.eigenoid.services |
public-gateway | api-dev.eigenoid.com | api-public-internal-dev.eigenoid.services |
Each Worker:
-
Strips client-injectable headers before forwarding — prevents spoofing of internal headers.
Stripped:cf-access-jwt-assertion,cf-access-client-id,cf-access-client-secret,x-internal-auth-token,x-forwarded-*,x-real-ip, hop-by-hop headers. -
Resolves
INTERNAL_AUTH_TOKENfrom the CF Secrets Store (eigenoidstore, IDe30a2aceebe34a80a10da2cc6bb208c4) via aSecretBinding. This is an async.get()call — not a plain string env var. -
Injects
X-Internal-Auth-Tokenheader into the proxied request. -
Proxies to a fixed origin (
ORIGIN_URLvar, e.g.https://api-admin-internal-dev.eigenoid.services). Fixed origin = SSRF-safe by construction. -
CORS: strict
Allowed-Originmatch from theALLOWED_ORIGINvar.
wrangler.toml pattern for a Worker binding the internal auth token:
[env.dev.vars]
ALLOWED_ORIGIN = "https://access-dev.eigenoid.services"
ORIGIN_URL = "https://api-admin-internal-dev.eigenoid.services"
[[env.dev.secrets_store_secrets]]
binding = "INTERNAL_AUTH_TOKEN"
store_id = "e30a2aceebe34a80a10da2cc6bb208c4"
secret_name = "gateway-dev-internal-auth-token"
Runtime secret access (env.ts):
// INTERNAL_AUTH_TOKEN is a SecretsStoreSecret, not a plain string.
// Always call .get() to resolve the value — never read it as a string directly.
export type SecretBinding = string | { get(): Promise<string> };
export async function resolveSecret(binding: SecretBinding): Promise<string> {
if (typeof binding === "string") return binding;
return binding.get();
}
Deploy: push to the dev branch triggers Workers Builds CI. No manual wrangler deploy needed for normal changes.
Related pages
- Authentication flow — how the token injected by Workers is validated downstream
- Adding a new API — Worker setup for new services