{"record":{"id":"886b17f8c8fe97fc","repo":"withastro/astro","slug":"serveronlymodule-886b17","errorCode":"ServerOnlyModule","errorMessage":"The \"astro:config/server\" module is only available server-side.","messagePattern":"The \"astro:config/server\" module is only available server-side\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/manifest/virtual-module.ts","lineNumber":88,"sourceCode":"\t\t\t\t\treturn RESOLVED_VIRTUAL_CLIENT_ID;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tload: {\n\t\t\tfilter: {\n\t\t\t\tid: new RegExp(`^(${RESOLVED_VIRTUAL_SERVER_ID}|${RESOLVED_VIRTUAL_CLIENT_ID})$`),\n\t\t\t},\n\t\t\thandler(id) {\n\t\t\t\tif (id === RESOLVED_VIRTUAL_CLIENT_ID) {\n\t\t\t\t\t// astro:config/client inlines values directly from settings instead of\n\t\t\t\t\t// importing from virtual:astro:manifest to avoid pulling server-only\n\t\t\t\t\t// virtual modules (virtual:astro:routes, virtual:astro:pages) into the\n\t\t\t\t\t// client environment where they are not available.\n\t\t\t\t\treturn { code: clientConfigCode };\n\t\t\t\t}\n\t\t\t\tif (id === RESOLVED_VIRTUAL_SERVER_ID) {\n\t\t\t\t\tif (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {\n\t\t\t\t\t\tthrow new AstroError({\n\t\t\t\t\t\t\t...AstroErrorData.ServerOnlyModule,\n\t\t\t\t\t\t\tmessage: AstroErrorData.ServerOnlyModule.message(VIRTUAL_SERVER_ID),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst code = `\nimport { manifest } from '${SERIALIZED_MANIFEST_ID}'\nimport { fromRoutingStrategy } from \"astro/app\";\n\nlet i18n = undefined;\nif (manifest.i18n) {\n i18n = {\n   defaultLocale: manifest.i18n.defaultLocale,\n   locales: manifest.i18n.locales,\n   routing: fromRoutingStrategy(manifest.i18n.strategy, manifest.i18n.fallbackType),\n   fallback: manifest.i18n.fallback,\n   domains: manifest.i18n.domains,\n };\n}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/manifest/virtual-module.ts#L70-L106","documentation":"The `astro:config/server` virtual module is the server-only half of the serialized config. When its `resolveId`/`load` handler runs under the Astro client environment (`environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client`), Astro throws `ServerOnlyModule` to keep server-only config (and any server virtual modules it pulls in) out of client bundles.","triggerScenarios":"Importing `astro:config/server` (directly or transitively) from code that resolves in the client environment — client components, `<script>` tags, client directive entrypoints.","commonSituations":"A shared utility that imports server config being pulled into a client-rendered component; a barrel file re-exporting `astro:config/server`; mixing server and client config imports in one module graph.","solutions":["Remove the `astro:config/server` import from any client-reachable module; use `astro:config/client` for client-safe config values.","Split server-only config consumers into separate files the browser never imports.","Trace the import graph to find the client entrypoint pulling in the server module and cut the edge."],"exampleFix":"// before — shared util imported on both sides\nimport { config } from 'astro:config/server'\nexport function getBase() { return config.base }\n\n// after — client code uses the client-safe module\nimport { config } from 'astro:config/client'\nexport function getBase() { return config.base }","handlingStrategy":"validation","validationCode":"// Static check: ensure no client-reachable file imports astro:config/server.\n// Use a grep/ESLint rule disallowing 'astro:config/server' outside server-only dirs.","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use astro:config/client for client code; reserve astro:config/server for server-only files.","Avoid barrel files mixing the two modules.","Audit the client bundle for server module leakage."],"tags":["security","config","vite","bundling","virtual-module"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}