full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -1,18 +1,14 @@
import { appendForwardSlash, prependForwardSlash } from "./path.js";
const clientAddressSymbol = Symbol.for("astro.clientAddress");
const clientLocalsSymbol = Symbol.for("astro.locals");
function createRequest({
base,
url,
headers,
clientAddress,
method = "GET",
body = void 0,
logger,
locals,
staticLike = false
isPrerendered = false,
routePattern,
init
}) {
const headersObj = staticLike ? void 0 : headers instanceof Headers ? headers : new Headers(
const headersObj = isPrerendered ? void 0 : headers instanceof Headers ? headers : new Headers(
// Filter out HTTP/2 pseudo-headers. These are internally-generated headers added to all HTTP/2 requests with trusted metadata about the request.
// Examples include `:method`, `:scheme`, `:authority`, and `:path`.
// They are always prefixed with a colon to distinguish them from other headers, and it is an error to add the to a Headers object manually.
@@ -20,33 +16,33 @@ function createRequest({
Object.entries(headers).filter(([name]) => !name.startsWith(":"))
);
if (typeof url === "string") url = new URL(url);
const imageEndpoint = prependForwardSlash(appendForwardSlash(base)) + "_image";
if (staticLike && url.pathname !== imageEndpoint) {
if (isPrerendered) {
url.search = "";
}
const request = new Request(url, {
method,
headers: headersObj,
// body is made available only if the request is for a page that will be on-demand rendered
body: staticLike ? null : body
body: isPrerendered ? null : body,
...init
});
if (staticLike) {
const _headers = request.headers;
const headersDesc = Object.getOwnPropertyDescriptor(request, "headers") || {};
if (isPrerendered) {
let _headers = request.headers;
const { value, writable, ...headersDesc } = Object.getOwnPropertyDescriptor(request, "headers") || {};
Object.defineProperty(request, "headers", {
...headersDesc,
get() {
logger.warn(
null,
`\`Astro.request.headers\` is unavailable in "static" output mode, and in prerendered pages within "hybrid" and "server" output modes. If you need access to request headers, make sure that \`output\` is configured as either \`"server"\` or \`output: "hybrid"\` in your config file, and that the page accessing the headers is rendered on-demand.`
`\`Astro.request.headers\` was used when rendering the route \`${routePattern}'\`. \`Astro.request.headers\` is not available on prerendered pages. If you need access to request headers, make sure that the page is server-rendered using \`export const prerender = false;\` or by setting \`output\` to \`"server"\` in your Astro config to make all your pages server-rendered by default.`
);
return _headers;
},
set(newHeaders) {
_headers = newHeaders;
}
});
} else if (clientAddress) {
Reflect.set(request, clientAddressSymbol, clientAddress);
}
Reflect.set(request, clientLocalsSymbol, locals ?? {});
return request;
}
export {