@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
ts 26 lines 809 Bytes
Raw
1 /// <reference types="vite/client" />
2 // Mirrors `@cloudflare/vite-plugin`'s `playground/spa-with-api/api/index.ts`.
3 import assetPath from "./asset.txt?no-inline";
4
5 interface Env {
6 ASSETS: Fetcher;
7 }
8
9 export default {
10 async fetch(request: Request, env: Env) {
11 const { pathname } = new URL(request.url);
12
13 if (pathname.startsWith("/api/")) {
14 if (pathname === "/api/asset") {
15 const response = await env.ASSETS.fetch(new URL(assetPath, request.url));
16 return new Response(`Modified: ${await response.text()}`);
17 }
18 return Response.json({ name: "Cloudflare" });
19 }
20
21 const response = await env.ASSETS.fetch(request);
22 const modified = new Response(response.body, response);
23 modified.headers.append("is-worker-response", "true");
24 return modified;
25 },
26 };