copyRequest() — astro Function Reference
Architecture documentation for the copyRequest() function in rewrite.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 93d8ff95_1c45_20a8_a760_1125b2b74931["copyRequest()"] 67024343_d7f2_f928_d5b2_367cfa846343["rewrite.ts"] 93d8ff95_1c45_20a8_a760_1125b2b74931 -->|defined in| 67024343_d7f2_f928_d5b2_367cfa846343 style 93d8ff95_1c45_20a8_a760_1125b2b74931 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/routing/rewrite.ts lines 156–189
export function copyRequest(
newUrl: URL,
oldRequest: Request,
isPrerendered: boolean,
logger: Logger,
routePattern: string,
): Request {
if (oldRequest.bodyUsed) {
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
}
return createRequest({
url: newUrl,
method: oldRequest.method,
body: oldRequest.body,
isPrerendered,
logger,
headers: isPrerendered ? {} : oldRequest.headers,
routePattern,
init: {
referrer: oldRequest.referrer,
referrerPolicy: oldRequest.referrerPolicy,
mode: oldRequest.mode,
credentials: oldRequest.credentials,
cache: oldRequest.cache,
redirect: oldRequest.redirect,
integrity: oldRequest.integrity,
signal: oldRequest.signal,
keepalive: oldRequest.keepalive,
// https://fetch.spec.whatwg.org/#dom-request-duplex
// @ts-expect-error It isn't part of the types, but undici accepts it and it allows to carry over the body to a new request
duplex: 'half',
},
});
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does copyRequest() do?
copyRequest() is a function in the astro codebase, defined in packages/astro/src/core/routing/rewrite.ts.
Where is copyRequest() defined?
copyRequest() is defined in packages/astro/src/core/routing/rewrite.ts at line 156.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free