Router
Source:
src/AWS/Website/Router.ts
Shared CloudFront front door with KV-based dynamic routing.
Router owns a single CloudFront distribution with a placeholder origin.
Routes are registered lazily via KV entries. A CloudFront Function reads the
KV store at the edge and dynamically sets the origin using
cf.updateRequestOrigin().
Sites register themselves by writing their file manifest and metadata into
the Router’s KV store. The Router’s CF function matches incoming requests to
routes by host pattern and path prefix, then delegates to routeSite() for
static site routing or directly sets URL/S3 origins.
Creating Routers
Section titled “Creating Routers”const router = yield* Router("WebsiteRouter", { domain: { name: "example.com", hostedZoneId },});Inline Routes
Section titled “Inline Routes”const router = yield* Router("WebsiteRouter", { routes: { "/*": { url: api.functionUrl }, },});