1import * as Alchemy from "alchemy";
2import * as Cloudflare from "alchemy/Cloudflare";
3import * as Effect from "effect/Effect";
4
5export default Alchemy.Stack(
6 "CloudflareFoldkitSsrExample",
7 {
8 providers: Cloudflare.providers(),
9 state: Cloudflare.state(),
10 },
11 Effect.gen(function* () {
12 const worker = yield* Cloudflare.Website.Foldkit("FoldkitSsr", {
13 // Rendering happens at the edge, so the deployment needs a Worker.
14 main: "src/worker.ts",
15 // Both settings are load-bearing, and getting either wrong fails
16 // quietly — the site serves 200s that carry an empty document.
17 //
18 // `notFoundHandling: "none"` lets a request that matches no file reach
19 // the Worker instead of being answered with the template.
20 // `htmlHandling: "none"` stops the asset layer resolving `/` to
21 // `/index.html` on its own, which would serve the unrendered template
22 // for the front page alone.
23 //
24 // Files still come straight from the asset layer; only page requests
25 // reach the Worker. `/index.html` keeps matching literally, which is
26 // where the Worker reads its shell from.
27 assets: {
28 htmlHandling: "none",
29 notFoundHandling: "none",
30 },
31 });
32
33 return {
34 url: worker.url,
35 };
36 }),
37);