1import * as Astro from "@alchemy.run/frontend-frameworks/astro";
2import cloudflare from "@alchemy.run/frontend-frameworks/astro/cloudflare";
3import { Assets, Text } from "@alchemy.run/cloudflare-runtime/core/bindings";
4import * as Options from "@alchemy.run/cloudflare-test-tools/e2e/Options";
5
6export const FIXTURE_VALUE = "hello-from-astro-binding";
7
8export default Options.make({
9 // Target-scoped config carriage (the canonical form): `target.cloudflare`
10 // carries the worker config (dev/build) and the miniflare preview config.
11 target: {
12 cloudflare: {
13 worker: {
14 compatibilityDate: "2026-03-10",
15 compatibilityFlags: ["nodejs_compat"],
16 worker: {
17 name: "fixtures-astro",
18 bindings: [
19 Assets.local("ASSETS"),
20 Text.local("FIXTURE_VALUE", FIXTURE_VALUE),
21 ],
22 assets: {
23 htmlHandling: "auto-trailing-slash",
24 notFoundHandling: "none",
25 },
26 },
27 },
28 preview: {
29 compatibilityDate: "2026-03-10",
30 compatibilityFlags: ["nodejs_compat"],
31 bindings: { FIXTURE_VALUE },
32 // Zero-config sessions: the built app reads the SESSION KV binding.
33 kvNamespaces: ["SESSION"],
34 assets: {
35 binding: "ASSETS",
36 routerConfig: {
37 has_user_worker: true,
38 invoke_user_worker_ahead_of_assets: false,
39 },
40 assetConfig: {
41 html_handling: "auto-trailing-slash",
42 not_found_handling: "none",
43 },
44 },
45 },
46 },
47 },
48 // The typed form: build the Cloudflare deploy target as a *value* from the
49 // shared worker options and pass it to the framework (`target:`). Astro
50 // config rides alongside (the dev toolbar would differ between dev and the
51 // built output, breaking the shared screenshots).
52 framework: (options) =>
53 Astro.layer({
54 target: cloudflare({
55 worker: Options.resolveCloudflareOptions(options).worker,
56 }),
57 astro: {
58 devToolbar: { enabled: false },
59 redirects: { "/old-about": "/about/" },
60 // Emit stylesheets as hashed /_astro/ assets (instead of inlining)
61 // so the generated _headers immutable Cache-Control rule is
62 // observable end-to-end in live mode.
63 build: { inlineStylesheets: "never" },
64 },
65 }),
66});