{"record":{"id":"8ca16b84d58fb0b8","repo":"withastro/astro","slug":"astro-site-inside-getstaticpaths-is-deprecated-and","errorCode":null,"errorMessage":"Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead","messagePattern":"Astro\\.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro\\. Use import\\.meta\\.env\\.SITE instead","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/runtime/server/astro-global.ts","lineNumber":19,"sourceCode":"import { ASTRO_GENERATOR } from '../../core/constants.js';\nimport { AstroError, AstroErrorData } from '../../core/errors/index.js';\nimport type { AstroGlobal } from '../../types/public/context.js';\n\nfunction createError(name: string) {\n\treturn new AstroError({\n\t\t...AstroErrorData.UnavailableAstroGlobal,\n\t\tmessage: AstroErrorData.UnavailableAstroGlobal.message(name),\n\t});\n}\n\n// This is used to create the top-level Astro global; the one that you can use\n// inside of getStaticPaths. See the `astroGlobalArgs` option for parameter type.\nexport function createAstro(site: string | undefined): AstroGlobal {\n\treturn {\n\t\t// TODO: throw in Astro 8\n\t\tget site() {\n\t\t\t// This is created inside of the runtime so we don't have access to the Astro logger.\n\t\t\tconsole.warn(\n\t\t\t\t`Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead`,\n\t\t\t);\n\t\t\treturn site ? new URL(site) : undefined;\n\t\t},\n\t\t// TODO: throw in Astro 8\n\t\tget generator() {\n\t\t\t// This is created inside of the runtime so we don't have access to the Astro logger.\n\t\t\tconsole.warn(\n\t\t\t\t`Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.`,\n\t\t\t);\n\t\t\treturn ASTRO_GENERATOR;\n\t\t},\n\t\tget callAction(): any {\n\t\t\tthrow createError('callAction');\n\t\t},\n\t\tget clientAddress(): any {\n\t\t\tthrow createError('clientAddress');\n\t\t},","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/withastro/astro/blob/3578d45d34226d63cff3d261c971c221de6794d2/packages/astro/src/runtime/server/astro-global.ts#L1-L37","documentation":"Inside getStaticPaths, Astro hands you a limited mock of the Astro global built by createAstro(). Reading Astro.site from that mock still returns the configured site (or undefined), but the property is deprecated: the getter logs a console.warn on every access and the source is explicitly marked to throw in Astro 7. The supported replacement is the SITE environment variable available to the same module via import.meta.env.","triggerScenarios":"Calling `Astro.site` inside an exported getStaticPaths() function — in .astro pages, endpoints, or integration-injected routes — during `astro dev` or `astro build`. Each property read fires the warning once (it is an inline console.warn in the getter, not a logged-once guard).","commonSituations":"Generating sitemap entries, canonical URLs, OG tags, or absolute links from the configured site inside getStaticPaths. Typically surfaces after upgrading to an Astro version that introduced this deprecation ahead of the Astro 7 removal, when CI or dev suddenly shows the warning on every build.","solutions":["Replace Astro.site with import.meta.env.SITE inside getStaticPaths, wrapping it in new URL(...) if you need a URL object","Make sure `site` is set in astro.config.mjs, otherwise import.meta.env.SITE is undefined","Move any other Astro-global reads (params/props/generator) out of getStaticPaths into the page component where the real Astro global exists"],"exampleFix":"// before\nexport async function getStaticPaths() {\n  const site = Astro.site; // deprecation warning on every build\n  return posts.map((p) => ({\n    params: { slug: p.slug },\n    props: { url: new URL(`/posts/${p.slug}`, site) },\n  }));\n}\n\n// after\nexport async function getStaticPaths() {\n  const site = new URL(import.meta.env.SITE);\n  return posts.map((p) => ({\n    params: { slug: p.slug },\n    props: { url: new URL(`/posts/${p.slug}`, site) },\n  }));\n}","handlingStrategy":"validation","validationCode":"// Helper used everywhere instead of the deprecated global — throws early if site is unset\nexport function getSite(): URL {\n  const site = import.meta.env.SITE;\n  if (!site) throw new Error('Set `site` in astro.config.mjs so import.meta.env.SITE is defined');\n  return new URL(site);\n}\n\n// inside getStaticPaths:\nconst site = getSite();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep the repo for `Astro.` reads inside getStaticPaths blocks and migrate them to import.meta.env.SITE / ASTRO_VERSION","Centralize site access in one getSite() helper so a future API change touches one file","Treat deprecation console.warn output as a CI failure before major Astro upgrades"],"tags":["astro","getstaticpaths","deprecation","astro-site","import-meta-env"],"backgroundTag":"deprecated-api-usage","analyzedSha":"3578d45d34226d63cff3d261c971c221de6794d2","analyzedAt":"2026-08-21T18:22:53.330Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}