{"record":{"id":"c642a286d216b73d","repo":"sveltejs/kit","slug":"keypath-must-be-a-valid-origin-received-in","errorCode":null,"errorMessage":"${keypath} must be a valid origin — received '${input}' which contains a path, query, or hash. Use the bare origin '${origin}' instead","messagePattern":"(.+?) must be a valid origin — received '(.+?)' which contains a path, query, or hash\\. Use the bare origin '(.+?)' instead","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":239,"sourceCode":"\n\t\t\ttry {\n\t\t\t\turl = new URL(input);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${keypath} must be a valid origin (e.g. 'https://my-site.com'). '${input}' could not be parsed as a URL`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (url.protocol !== 'http:' && url.protocol !== 'https:') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${keypath} must be a valid origin — only 'http' and 'https' protocols are supported, received '${url.protocol}'`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst origin = url.origin;\n\n\t\t\tif (input !== origin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${keypath} must be a valid origin — received '${input}' which contains a path, query, or hash. Use the bare origin '${origin}' instead`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn origin;\n\t\t}),\n\t\trelative: boolean(true)\n\t}),\n\n\tpreprocess: any(),\n\n\tprerender: object({\n\t\tconcurrency: number(1),\n\t\tcrawl: boolean(true),\n\t\tentries: validate(['*'], (input, keypath) => {\n\t\t\tif (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {\n\t\t\t\tthrow new Error(`${keypath} must be an array of strings`);\n\t\t\t}","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L221-L257","documentation":"SvelteKit validates `kit.prerender.origin` (or other origin options) by parsing the supplied value as a URL and comparing it to the URL's origin part. If the configured value includes a path, query string, or hash — i.e. it is not a bare origin — the validator throws this error and suggests the correct bare origin to use.","triggerScenarios":"Setting `kit.prerender.origin` to a full URL with a path or query, e.g. 'https://example.com/app' or 'https://example.com/?x=1', then running a build or `vite dev` where config is validated via validate_config/options.","commonSituations":"Copying a full site URL (including a deployed app sub-path or a URL with utm/hash fragments) from the browser address bar into svelte.config.js instead of stripping it down to scheme + host + port.","solutions":["Replace the configured value with only the origin portion (scheme + host + port), e.g. 'https://example.com' — the error message tells you the exact bare origin to use.","If your site is served from a sub-path, keep the origin bare and configure the sub-path via `paths.base` instead.","Re-run the build/dev command to confirm config validation passes."],"exampleFix":"// before\nconst config = {\n  kit: { prerender: { origin: 'https://example.com/docs' } }\n};\n// after\nconst config = {\n  kit: { prerender: { origin: 'https://example.com' } }\n};","handlingStrategy":"validation","validationCode":"function isBareOrigin(value) {\n  try {\n    const url = new URL(value);\n    return url.origin === value;\n  } catch {\n    return false;\n  }\n}\nif (!isBareOrigin(cfg.kit?.prerender?.origin)) throw new Error('prerender.origin must be a bare origin');","typeGuard":"function isBareOrigin(v) { try { return typeof v === 'string' && new URL(v).origin === v; } catch { return false; } }","tryCatchPattern":"try {\n  build({ config: cfg });\n} catch (e) {\n  if (String(e.message).includes('must be a valid origin')) {\n    cfg.kit.prerender.origin = new URL(cfg.kit.prerender.origin).origin; // auto-strip\n  } else throw e;\n}","preventionTips":["Strip paths/queries with new URL(x).origin before assigning origin options.","Use paths.base for sub-path deployments, never the origin option.","Add a config sanity-check script that parses the origin before building."],"tags":["sveltekit","config-validation","prerender","origin"],"backgroundTag":"invalid-origin-config","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}