1/**
2 * `@alchemy.run/frontend-frameworks/astro/entrypoints/node-server` — the
3 * Node container server entrypoint the Node deploy target pins as the
4 * adapter's `serverEntrypoint`.
5 *
6 * Compiled by astro's `ssr` environment build (the `astro/app/entrypoint`
7 * virtual modules only resolve there), it builds the production `App` from
8 * the serialized manifest and exports a web-standard fetch `handler`. The
9 * target's finishing pass wraps this handler in a Node HTTP program that
10 * serves `clientDirectory` first, then falls through here.
11 */
12import { createApp } from "astro/app/entrypoint";
13import { setGetEnv } from "astro/env/setup";
14
15// astro:env `getSecret` reads process.env on the Node runtime.
16setGetEnv((key) => process.env[key]);
17
18const app = createApp();
19
20export const handler = (request: Request) =>
21 app.render(request, {
22 addCookieHeader: true,
23 clientAddress:
24 request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ||
25 undefined,
26 });