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

main
md 56 lines 2.9 KB
Rendered Raw
1 # @fixtures/astro
2
3 E2e fixture for `@alchemy.run/frontend-frameworks/astro` — a wrangler-free Astro app on
4 Cloudflare Workers, driven through the e2e harness's `Framework` service
5 (no `wrangler.json`). The project's own `astro.config.mjs` loads natively;
6 the toolchain's config is an inline overlay astro merges over it.
7
8 `e2e.config.ts` uses the target-scoped config carriage (`target.cloudflare`)
9 and passes the Cloudflare deploy target as a typed _value_
10 (`cloudflare({ worker })` from `@alchemy.run/frontend-frameworks/astro/cloudflare`) to
11 `Astro.make`.
12
13 The app exercises:
14
15 - a real user `astro.config.mjs` honored natively: a user integration
16 injects the on-demand `/user-integration` route, and a user `vite.define`
17 setting is rendered into its HTML — both asserted e2e in dev and live
18 - an on-demand SSR page (`/`) reading a `Text.local` binding via
19 `cloudflare:workers`, with a client-interactive counter script
20 - middleware (`src/middleware.ts`): writes `Astro.locals` (rendered by
21 `/locals`) and mutates response headers (`x-middleware`) on on-demand routes
22 - a `redirects` config entry (`/old-about` → `/about/`): emitted into the
23 generated `_redirects` file at build time (served by the asset layer ahead
24 of the worker in live mode) and handled dynamically by the worker in dev
25 (the integration sets `build: { redirects: false }`)
26 - zero-config sessions (`/session`): no session driver configured anywhere —
27 the integration defaults to the Cloudflare KV driver (binding `SESSION`),
28 auto-injects an in-memory local KV namespace in dev, and the live preview
29 supplies a miniflare KV namespace (`preview.kvNamespaces`)
30 - the generated `_headers` file: immutable `Cache-Control` on the hashed
31 `/_astro/*` assets, asserted end-to-end in live mode
32 - a prerendered page (`/about/`) served from assets in production and by
33 Astro's node prerender middleware in dev
34 - a content-collection-driven static page (`/posts/hello-world/`): glob
35 loader over `src/posts/*.md`, `getStaticPaths` + `render` from
36 `astro:content`, prerendered at build time
37 - API routes returning JSON (`/api/hello`, reads the binding + asserts the
38 `ASSETS` binding exists) and binary data (`/api/binary`,
39 `application/octet-stream`)
40 - a `public/` static asset (`/robots.txt`)
41 - the 404 fallback path through `env.ASSETS.fetch`
42
43 Known limitations (see the package README for details): prerendering runs in
44 **node**, not workerd, so prerendered pages must not import
45 `cloudflare:workers` at render time; the image service is **passthrough**
46 (no sharp in workerd); middleware header mutations are only observable on
47 on-demand routes (prerendered pages are static files in production).
48
49 ## Commands
50
51 ```sh
52 bun run dev # astro dev with the ssr environment in workerd (port 3102)
53 bun run build # astro build -> dist/ + dist/build.json
54 bun run preview # miniflare over dist/build.json
55 bun run test # playwright: live (miniflare) + dev projects
56 ```