{"record":{"id":"f9125f7e36e0b5ef","repo":"sveltejs/kit","slug":"keypath-must-be-a-valid-origin-only-http-an","errorCode":null,"errorMessage":"${keypath} must be a valid origin — only 'http' and 'https' protocols are supported, received '${url.protocol}'","messagePattern":"(.+?) must be a valid origin — only 'http' and 'https' protocols are supported, received '(.+?)'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":231,"sourceCode":"\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\n\t\t\treturn origin;\n\t\t}),\n\t\trelative: boolean(true)\n\t}),\n\n\tpreprocess: any(),","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L213-L249","documentation":"Beyond parseability, the origin must use the `http:` or `https:` protocol. SvelteKit prerenders real HTTP pages, so schemes like `ftp:`, `file:`, `ws:` or custom app schemes are rejected, with the offending protocol included in the message.","triggerScenarios":"`prerender: { origin: 'ftp://my-site.com' }`, `origin: 'file:///path'`, or a custom scheme like `app://host` — anything where `url.protocol` is neither `http:` nor `https:`.","commonSituations":"Pasting a local file URL during local testing; using a websocket or app-deep-link scheme by mistake; npm package URLs (`package://`) pasted into config.","solutions":["Switch to `https://` (or `http://` for local testing): `https://my-site.com`","If you need local prerendering, use `http://localhost` or `http://sveltekit-prerender` as appropriate","Validate the protocol before assigning: `['http:', 'https:'].includes(new URL(v).protocol)`"],"exampleFix":"// before\nprerender: { origin: 'file:///srv/site' }\n// after\nprerender: { origin: 'https://my-site.com' }","handlingStrategy":"validation","validationCode":"const origin = config.prerender?.origin;\nif (origin !== undefined) {\n  const protocol = new URL(origin).protocol;\n  if (protocol !== 'http:' && protocol !== 'https:') {\n    throw new Error(`prerender.origin must use http/https, got ${protocol}`);\n  }\n}","typeGuard":"function isHttpOrigin(v) {\n  try {\n    const p = new URL(v).protocol;\n    return p === 'http:' || p === 'https:';\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  assertHttpOrigin(config.prerender?.origin);\n} catch (e) {\n  if (String(e.message).includes(\"only 'http' and 'https' protocols\")) {\n    console.error('Replace the scheme with https:// (or http:// for local testing)');\n  }\n  throw e;\n}","preventionTips":["Only use `http://` or `https://` schemes in prerender.origin","Use `http://localhost` or `http://sveltekit-prerender` for local prerender testing, never `file://`","Add a pre-build config check asserting the origin protocol"],"tags":["config","url","prerender","protocol"],"backgroundTag":"invalid-url-format","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}