default.fetch() — astro Function Reference
Architecture documentation for the default.fetch() function in entrypoint.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ca769a02_99a1_c3c3_5e70_7a41d18bfb2c["default.fetch()"] 888c71eb_1227_93b2_edd4_456430022b2c["entrypoint.ts"] ca769a02_99a1_c3c3_5e70_7a41d18bfb2c -->|defined in| 888c71eb_1227_93b2_edd4_456430022b2c style ca769a02_99a1_c3c3_5e70_7a41d18bfb2c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/vercel/src/serverless/entrypoint.ts lines 16–62
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url);
const realPath =
request.headers.get(ASTRO_PATH_HEADER) ?? url.searchParams.get(ASTRO_PATH_PARAM);
if (typeof realPath === 'string') {
url.pathname = realPath;
request = new Request(url.toString(), {
method: request.method,
headers: request.headers,
body: request.body,
});
}
const routeData = app.match(request);
let locals: Record<string, unknown> = {};
const astroLocalsHeader = request.headers.get(ASTRO_LOCALS_HEADER);
const middlewareSecretHeader = request.headers.get(ASTRO_MIDDLEWARE_SECRET_HEADER);
if (astroLocalsHeader) {
if (middlewareSecretHeader !== middlewareSecret) {
return new Response('Forbidden', { status: 403 });
}
// hide the secret from the rest of user code
request.headers.delete(ASTRO_MIDDLEWARE_SECRET_HEADER);
locals = JSON.parse(astroLocalsHeader);
}
// https://vercel.com/docs/deployments/skew-protection#supported-frameworks
if (skewProtection && process.env.VERCEL_SKEW_PROTECTION_ENABLED === '1') {
request.headers.set('x-deployment-id', process.env.VERCEL_DEPLOYMENT_ID!);
}
const response = await app.render(request, {
routeData,
clientAddress: request.headers.get('x-forwarded-for') ?? undefined,
locals,
});
if (app.setCookieHeaders) {
for (const setCookieHeader of app.setCookieHeaders(response)) {
response.headers.append('Set-Cookie', setCookieHeader);
}
}
return response;
},
Domain
Subdomains
Source
Frequently Asked Questions
What does default.fetch() do?
default.fetch() is a function in the astro codebase, defined in packages/integrations/vercel/src/serverless/entrypoint.ts.
Where is default.fetch() defined?
default.fetch() is defined in packages/integrations/vercel/src/serverless/entrypoint.ts at line 16.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free