{"record":{"id":"ebaa5bcb2371b189","repo":"withastro/astro","slug":"missinggetfontfilerequesturl","errorCode":"MissingGetFontFileRequestUrl","errorMessage":"`experimental_getFontFileURL()` requires the request URL with on-demand rendering.","messagePattern":"`experimental_getFontFileURL\\(\\)` requires the request URL with on-demand rendering\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/fonts/infra/ssr-runtime-font-file-url-resolver.ts","lineNumber":30,"sourceCode":"\tconstructor({\n\t\turls,\n\t}: {\n\t\turls: Set<string>;\n\t}) {\n\t\tthis.#urls = urls;\n\t}\n\n\tresolve(url: string, requestUrl: URL | undefined): string | null {\n\t\tif (!this.#urls.has(url)) {\n\t\t\treturn null;\n\t\t}\n\t\t// assetsPrefix\n\t\tif (!url.startsWith('/')) {\n\t\t\treturn url;\n\t\t}\n\t\t// We need the request URL to call the current server\n\t\tif (!requestUrl) {\n\t\t\tthrow new AstroError(MissingGetFontFileRequestUrl);\n\t\t}\n\t\treturn `${requestUrl.origin}${url}`;\n\t}\n}\n","sourceCodeStart":12,"sourceCodeEnd":35,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/assets/fonts/infra/ssr-runtime-font-file-url-resolver.ts#L12-L35","documentation":"Thrown by SSRRuntimeFontFileURLResolver.resolve when an on-demand (SSR) rendering call needs to build an absolute font file URL but no request URL is available. The resolver only knows the request origin if the caller supplies requestUrl; without it, it cannot construct `${requestUrl.origin}${url}` and throws MissingGetFontFileRequestUrl.","triggerScenarios":"Calling resolve(url, requestUrl) where url is a known stored path that starts with '/' (i.e. not an assetsPrefix path) and requestUrl is undefined. This happens in on-demand rendering when experimental_getFontFileURL() is invoked outside a request context.","commonSituations":"Using experimental_getFontFileURL() during SSR build-time prerendering, in a context without an active request (e.g. a top-level module evaluation or a scheduled job), or with an adapter that does not propagate the request URL to the resolver.","solutions":["Call experimental_getFontFileURL() only within an on-demand-rendered request handler where the request URL is in scope.","If prerendering, switch the route to static output or pass the request URL explicitly.","Verify the adapter forwards the original request URL into the Astro pipeline.","For non-request contexts, use the static (build-time) font URL instead of the SSR resolver."],"exampleFix":"// before - called at module load, no request\nexport const url = experimental_getFontFileURL(myFont);\n\n// after - called inside a request handler\nexport const GET = ({ request }) =>\n  new Response(experimental_getFontFileURL(myFont, { requestUrl: new URL(request.url) }));","handlingStrategy":"type-guard","validationCode":"function hasRequestUrl(ctx: { request?: Request }): ctx is { request: Request } {\n  return !!ctx.request && !!ctx.request.url;\n}","typeGuard":"function hasRequestUrl(ctx: { request?: Request }): ctx is { request: Request } {\n  return !!ctx.request && !!ctx.request.url;\n}","tryCatchPattern":"if (!requestUrl) { /* do not call SSR resolver; use static font URL or 500 */ }\nelse { resolver.resolve(url, requestUrl); }","preventionTips":["Only call experimental_getFontFileURL() inside an on-demand request handler.","Pass the request URL explicitly through every layer that resolves font URLs.","Use static output for routes that must compute font URLs without a request."],"tags":["fonts","ssr","request-context","config"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}