How sudodevstudio/fastly-for-astro works
This is an Astro adapter that turns an Astro server build into a Fastly Compute application. The main request path receives a Fastly request, tries KV-backed static publishing except for server-island URLs, then invokes Astro SSR; the handler adds cache/security headers and optional observability. Build-time adapter configuration and generated runtime assets support that path, while encryption shims enable server-island support. The request and handler links are shown in excerpts; KV publishing and several advertised capabilities are documented but their implementation is not fully sampled.
Main entry points: compute-entry.js Compute Entry Template · index.ts Adapter Integration · handler.ts SSR Request Handler · generate-compute-app.ts Compute App Generation
Components 19
Adapter and Build
- Adapter Integration
src/index.ts - Option Resolution
src/options.ts - Compute App Generation
src/build/generate-compute-app.ts - Runtime Config
src/build/runtime-config.ts - Static Publish Config
templates/publish-content.config.js - Publisher Runtime Config
templates/static-publish.rc.js
Fastly Request Runtime
- Compute Entry Template
templates/compute-entry.js - Static Publisher
templates/compute-entry.js - KV Static Assets
Astro Rendering
- Astro Server Entry
src/runtime/server-entry.ts - SSR Request Handler
src/runtime/handler.ts - URL Reconstruction
src/runtime/path.ts
Response Policy
- Cache and Security
src/runtime/headers.ts - Request Observability
src/runtime/observability.ts
Islands and Crypto
- Astro Server Islands
- Astro Encryption Shim
src/runtime/shims/astro-encryption.ts - AES-GCM Polyfill
templates/crypto-polyfill.js
Other components
- Astro App
- Fastly Compute
Connections 20
- Astro App → Adapter Integration: configures
README.md - Adapter Integration → Option Resolution: resolves options
src/index.ts - Adapter Integration → Runtime Config: writes config
src/index.ts - Adapter Integration → Compute App Generation: generates app
src/index.ts - Compute App Generation → Compute Entry Template: uses template
- Fastly Compute → Compute Entry Template: dispatches request
templates/compute-entry.js - Compute Entry Template → Static Publisher: tries static lookup
templates/compute-entry.js - Static Publisher → KV Static Assets: serves published assets
- Compute Entry Template → Astro Server Entry: imports handler
templates/compute-entry.js - Astro Server Entry → SSR Request Handler: creates handler
src/runtime/server-entry.ts - SSR Request Handler → URL Reconstruction: reconstructs URL
src/runtime/handler.ts - SSR Request Handler → Cache and Security: classifies and applies
src/runtime/handler.ts - SSR Request Handler → Request Observability: records timings
src/runtime/handler.ts - SSR Request Handler → Astro App: renders app routes
src/runtime/handler.ts - Compute Entry Template → Astro Server Islands: routes island requests
templates/compute-entry.js - Adapter Integration → Astro Encryption Shim: aliases Astro encryption
src/index.ts - Compute Entry Template → AES-GCM Polyfill: installs polyfill
templates/compute-entry.js - Astro Server Islands → Astro Encryption Shim: encrypts island props
- Static Publish Config → KV Static Assets: configures publishing
- Publisher Runtime Config → Static Publisher: configures publisher