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-ssr-binding";
7
8export default Options.make({
9 // Target-scoped config carriage: `target.cloudflare` carries the worker
10 // 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-ssr",
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 // Deliberately NO `astro:` overrides here — unlike packages/frontend-frameworks/fixtures/astro, this
49 // fixture's Astro configuration lives in its real `astro.config.mjs`,
50 // which the integration must load and honor (the user-config principle).
51 framework: (options) =>
52 Astro.layer({
53 target: cloudflare({
54 worker: Options.resolveCloudflareOptions(options).worker,
55 }),
56 }),
57});