The scaffoldedDocumentation Index
Fetch the complete documentation index at: https://docs.deep.space/llms.txt
Use this file to discover all available pages before exploring further.
worker.ts already uses these for every cross-worker call. They prefer service bindings (set up automatically on deploy) and fall back to HTTPS URLs in local dev.
apiWorkerFetch(env, path, init?)
Fetch the api-worker (Stripe, integrations, profiles, OAuth, usage tracking).
API_WORKER service binding; falls back to API_WORKER_URL. Throws an actionable Error if neither is configured.
platformWorkerFetch(env, pathOrRequest, init?)
Fetch the platform-worker (cross-app DOs, R2 file gateway, WebSocket multiplexing).
Request, so you can hand off c.req.raw derivatives with method/headers/body intact:
wsRoute in the example above is not an SDK export - it’s a small helper defined locally in the scaffolded worker.ts (around line 345 of templates/starter/worker.ts). It owns the JWT verification + URL rewriting boilerplate for WebSocket routes. Apps are free to edit or replace it.
For PNG capture against an *.app.space / *.deep.space URL, prefer the higher-level captureScreenshot wrapper instead of calling platformWorkerFetch against /internal/screenshot yourself - it owns the HMAC headers and the null-on-failure contract.
authWorkerFetch(env, path, init?)
Fetch the auth-worker (Better Auth, JWT issuance, OAuth flows).
Set-Cookie headers verbatim over plain HTTPS. (Service bindings strip some headers in transit.) Throws if AUTH_WORKER_URL is missing.
resolveApiTransport(env)
Exported for the AI helper, which needs the URL form to rewrite an internal https://api-worker.internal placeholder before calling provider SDKs. Most apps don’t need this.
Production note
Cross-worker calls over plain*.workers.dev URLs return Cloudflare error 1042 in production. The service binding is the only working transport for deployed apps; the URL fallback is a dev-only convenience the CLI writes into .dev.vars.
If a deployed app needs apiWorkerFetch or platformWorkerFetch, the corresponding [[services]] binding must be in wrangler.toml:
R2 helpers
createScopedR2Handler(config)
Factory that builds a route handler for prefix-scoped R2 reads/writes. The scaffold uses this implicitly via the useR2Files client hook - most apps don’t call it directly.
..) is rejected at the entry point, and mutations require a non-null userId by default.
See also
- Architecture concepts - when to add the platform binding
- File uploads guide