{"record":{"id":"cc283dc2cee74732","repo":"sveltejs/kit","slug":"keypath-must-be-a-valid-origin-e-g-https-m","errorCode":null,"errorMessage":"${keypath} must be a valid origin (e.g. 'https://my-site.com'). '${input}' could not be parsed as a URL","messagePattern":"(.+?) must be a valid origin \\(e\\.g\\. 'https://my-site\\.com'\\)\\. '(.+?)' could not be parsed as a URL","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":225,"sourceCode":"\n\t\t\t\tif (input.endsWith('/')) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${keypath} option must not end with '/'. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn input;\n\t\t}),\n\t\torigin: validate(undefined, (input, keypath) => {\n\t\t\tassert_string(input, keypath);\n\n\t\t\tlet url;\n\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","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L207-L243","documentation":"`prerender.origin` (validated here) must be a parseable URL, since SvelteKit uses it to resolve absolute URLs during prerendering. If `new URL(input)` throws, the config value is not a valid URL and this error is thrown including the bad input.","triggerScenarios":"`prerender: { origin: 'my-site.com' }` (missing scheme) or `origin: 'https'`/`origin: ''` — any string the `URL` constructor cannot parse.","commonSituations":"Forgetting `https://` in svelte.config.js; env var `ORIGIN` unset so an empty or partial string is used; trailing whitespace or typos in CI-configured origins.","solutions":["Include the full scheme: `https://my-site.com`","Verify with `new URL(value)` in Node before assigning","If the value comes from an env var, check it is set and non-empty: `origin: process.env.ORIGIN ?? 'https://my-site.com'`","Trim whitespace from env-derived values"],"exampleFix":"// before\nprerender: { origin: 'my-site.com' }\n// after\nprerender: { origin: 'https://my-site.com' }","handlingStrategy":"validation","validationCode":"const origin = config.prerender?.origin;\nif (origin !== undefined) {\n  try {\n    new URL(origin);\n  } catch {\n    throw new Error(`prerender.origin is not a valid URL: '${origin}'`);\n  }\n}","typeGuard":"function isParseableUrl(v) {\n  if (typeof v !== 'string') return false;\n  try {\n    new URL(v);\n    return true;\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  assertOrigin(config.prerender?.origin);\n} catch (e) {\n  if (String(e.message).includes('could not be parsed as a URL')) {\n    console.error('Include the full scheme, e.g. https://my-site.com');\n  }\n  throw e;\n}","preventionTips":["Always write origins with scheme and host: `https://example.com`","Guard env-derived origins with a default: `process.env.ORIGIN ?? 'https://example.com'`","Trim and validate env vars in CI before they reach svelte.config.js"],"tags":["config","url","prerender","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}