| 1 | // Worker-in-front-of-static-site: assets are matched first |
| 2 | // (`runWorkerFirst` is unset), so this worker only receives requests no |
| 3 | // static asset answers — the API route and everything unmatched |
| 4 | // (`not_found_handling: "none"` delegates 404s here). |
| 5 | export default { |
| 6 | async fetch(request: Request) { |
| 7 | const url = new URL(request.url); |
| 8 | if (url.pathname === "/api/hello") { |
| 9 | return Response.json({ message: "Hello World", source: "worker" }); |
| 10 | } |
| 11 | return new Response("Not Found", { status: 404 }); |
| 12 | }, |
| 13 | }; |