{"record":{"id":"6de4a1a4166f1e2e","repo":"withastro/astro","slug":"please-use-astro-url-instead","errorCode":null,"errorMessage":"Please use Astro.url instead.","messagePattern":"Please use Astro\\.url instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/integrations/netlify/src/index.ts","lineNumber":556,"sourceCode":"\t\t\t\t// Import Deno polyfill for `process.env` at the top of the file\n\t\t\t\tjs: 'import process from \"node:process\";',\n\t\t\t},\n\t\t});\n\t}\n\n\tfunction getLocalDevNetlifyContext(req: IncomingMessage): Context {\n\t\tconst isHttps = req.headers['x-forwarded-proto'] === 'https';\n\t\tconst parseBase64JSON = <T = unknown>(header: string): T | undefined => {\n\t\t\tif (typeof req.headers[header] === 'string') {\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(Buffer.from(req.headers[header] as string, 'base64').toString('utf8'));\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t};\n\n\t\tconst context: Context = {\n\t\t\tget url(): never {\n\t\t\t\tthrow new Error('Please use Astro.url instead.');\n\t\t\t},\n\t\t\t// The dev server is a long running process, so promises will run even with a noop\n\t\t\twaitUntil: () => {},\n\t\t\taccount: parseBase64JSON('x-nf-account-info') ?? {\n\t\t\t\tid: 'mock-netlify-account-id',\n\t\t\t},\n\t\t\tdeploy: {\n\t\t\t\tcontext: 'dev',\n\t\t\t\tid:\n\t\t\t\t\ttypeof req.headers['x-nf-deploy-id'] === 'string'\n\t\t\t\t\t\t? req.headers['x-nf-deploy-id']\n\t\t\t\t\t\t: 'mock-netlify-deploy-id',\n\t\t\t\tpublished: false,\n\t\t\t},\n\t\t\tsite: parseBase64JSON('x-nf-site-info') ?? {\n\t\t\t\tid: 'mock-netlify-site-id',\n\t\t\t\tname: 'mock-netlify-site.netlify.app',\n\t\t\t\turl: `${isHttps ? 'https' : 'http'}://localhost:${isRunningInNetlify ? 8888 : 4321}`,","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/netlify/src/index.ts#L538-L574","documentation":"In local dev, the Netlify adapter constructs a mock `Context` (Netlify Function context). `context.url` is defined as `get url(): never` that always throws, because Astro exposes the same data via `Astro.url`. Netlify's `url` field is intentionally unavailable to prevent divergence between the request URL and Astro's canonical URL.","triggerScenarios":"Calling `Astro.locals.netlify.context.url` (or however the adapter exposes `context`) in dev. Code written for vanilla Netlify Functions that reads `context.url` and is reused inside an Astro handler. Logging/debugging that enumerates context keys.","commonSituations":"Porting Netlify Function code into Astro endpoints. Reading the whole context object for debugging (the getter throws on access).","solutions":["Use `Astro.url` for the request URL.","If you need original Netlify context fields other than url/cookies/params/rewrite/next, read them from `context` directly.","Remove any code that destructures or serializes the whole `context` object in dev."],"exampleFix":"// before\nconst url = context.url;\n\n// after\nconst url = Astro.url;","handlingStrategy":"validation","validationCode":"function getRequestUrl(Astro: any): URL {\n  // Never read context.url; prefer Astro.url\n  return Astro.url;\n}","typeGuard":"function hasAstroUrl(Astro: any): Astro is { url: URL } {\n  return Astro?.url instanceof URL;\n}","tryCatchPattern":null,"preventionTips":["Always use `Astro.url` for the request URL.","Avoid enumerating or serializing the Netlify context object in dev.","Keep Astro-specific code separate from raw Netlify Function code."],"tags":["netlify","dev-server","deprecation","ssr"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}