{"record":{"id":"90900a1d407cd00a","repo":"sveltejs/kit","slug":"keypath-option-must-either-be-the-empty-string","errorCode":null,"errorMessage":"${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths","messagePattern":"(.+?) option must either be the empty string or a root-relative path that starts but doesn't end with '/'\\. See https://svelte\\.dev/docs/kit/configuration#paths","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":191,"sourceCode":"\t\t);\n\t}),\n\n\toutDir: string('.svelte-kit'),\n\n\toutput: object({\n\t\tlinkHeaderPreload: boolean(false),\n\t\tpreloadStrategy: removed(\n\t\t\t(keypath) => `\\`${keypath}\\` has been removed. modulepreload will always be used`\n\t\t),\n\t\tbundleStrategy: list(['split', 'single', 'inline'])\n\t}),\n\n\tpaths: object({\n\t\tbase: validate('', (input, keypath) => {\n\t\t\tassert_string(input, keypath);\n\n\t\t\tif (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn input;\n\t\t}),\n\t\tassets: validate('', (input, keypath) => {\n\t\t\tassert_string(input, keypath);\n\n\t\t\tif (input) {\n\t\t\t\tif (!/^[a-z]+:\\/\\//.test(input)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${keypath} option must be an absolute path, if specified. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (input.endsWith('/')) {\n\t\t\t\t\tthrow new Error(","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L173-L209","documentation":"`paths.base` must be either the empty string or a root-relative path that starts with `/` but does not end with `/`. SvelteKit enforces this so URLs are composed unambiguously. `assert_string` also guarantees it is a string first.","triggerScenarios":"`paths.base: 'app'` (no leading slash), `paths.base: '/app/'` (trailing slash), or a non-string value that passes string assertion only when it is a string but malformed.","commonSituations":"Deploying under a subpath and writing the subpath without a leading slash; copying GitHub Pages examples with trailing slashes; env vars like `BASE_PATH=app/` with trailing slash.","solutions":["Use `''` (empty string) if the app is served from the domain root","Otherwise use a path starting with `/` and not ending with `/`: `/my-app`","Normalize env-derived values: `base.replace(/\\/$/, '')` and ensure a leading `/`"],"exampleFix":"// before\npaths: { base: 'my-app/' }\n// after\npaths: { base: '/my-app' }","handlingStrategy":"validation","validationCode":"const base = config.paths?.base;\nif (base !== undefined && base !== '' && (!base.startsWith('/') || base.endsWith('/'))) {\n  throw new Error('paths.base must be \"\" or start with \"/\" and not end with \"/\"');\n}","typeGuard":"function isValidBasePath(v) {\n  return v === undefined || v === '' || (typeof v === 'string' && v.startsWith('/') && !v.endsWith('/'));\n}","tryCatchPattern":"try {\n  assertBasePath(config.paths?.base);\n} catch (e) {\n  if (String(e.message).includes(\"paths.base option must either be the empty string\")) {\n    console.error('Use \"\" or a path like /my-app (no trailing slash)');\n  }\n  throw e;\n}","preventionTips":["Normalize env-derived base paths: strip trailing `/`, ensure leading `/`","Prefer omitting `base` entirely when serving from the domain root","Test deploys to subpaths locally with `vite preview` before shipping"],"tags":["config","paths","validation"],"backgroundTag":"invalid-base-path","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}