The best way to control Claude Code, Codex and more from any computer or phone
| 1 | interface Fetcher { |
| 2 | fetch(request: Request): Promise<Response>; |
| 3 | } |
| 4 | |
| 5 | /** |
| 6 | * The app's Worker: the client build, plus `/api` forwarded to the bank over |
| 7 | * a service binding. One origin for both, so the session cookie is |
| 8 | * first-party and reaches every call and every live read's WebSocket. |
| 9 | */ |
| 10 | export default { |
| 11 | fetch(request: Request, env: { readonly ASSETS: Fetcher; readonly BANK: Fetcher }) { |
| 12 | const { pathname } = new URL(request.url); |
| 13 | return pathname.startsWith("/api") ? env.BANK.fetch(request) : env.ASSETS.fetch(request); |
| 14 | }, |
| 15 | }; |