vitejs/vite · error · Error
The value passed to "base" option was malformed. It should b
Error message
The value passed to "base" option was malformed. It should be a valid URL.
What it means
In decodeBase (config.ts:2336-2343), Vite runs decodeURI on the resolved base value; if the value contains malformed percent-encoding (e.g. a stray '%' not forming a valid escape), decodeURI throws URIError which Vite re-wraps as 'The value passed to base option was malformed'. The base must be a valid, decodable URL/path.
Source
Thrown at packages/vite/src/node/config.ts:2340
}
// parse base when command is serve or base is not External URL
if (!isBuild || !isExternal) {
base = new URL(base, 'http://vite.dev').pathname
// ensure leading slash
if (base[0] !== '/') {
base = '/' + base
}
}
return base
}
function decodeBase(base: string): string {
try {
return decodeURI(base)
} catch {
throw new Error(
'The value passed to "base" option was malformed. It should be a valid URL.',
)
}
}
export function sortUserPlugins(
plugins: (Plugin | Plugin[])[] | undefined,
): [Plugin[], Plugin[], Plugin[]] {
const prePlugins: Plugin[] = []
const postPlugins: Plugin[] = []
const normalPlugins: Plugin[] = []
if (plugins) {
plugins.flat().forEach((p) => {
if (p.enforce === 'pre') prePlugins.push(p)
else if (p.enforce === 'post') postPlugins.push(p)
else normalPlugins.push(p)
})View on GitHub (pinned to 89620f09af)
Solutions
- Correct the base to a valid path/URL, e.g. '/my-app/'.
- Percent-encode any literal special characters properly (e.g. '%25' for a literal '%') or remove them.
- Use an absolute URL or a simple leading-slash path as the docs recommend.
Example fix
// before
export default { base: '/vite%/' }
// after
export default { base: '/vite/' } Defensive patterns
Strategy: validation
Validate before calling
function assertValidBase(base: string) {
try { decodeURI(base) } catch { throw new Error(`Malformed base: ${base}`) }
} Type guard
function isDecodableBase(base: string): boolean {
try { decodeURI(base); return true } catch { return false }
} Prevention
- Keep base a simple leading-slash path or absolute URL.
- Percent-encode literal special characters correctly (e.g. %25 for %).
- Validate base in CI config checks.
When it happens
Trigger: Setting config base to a string containing an invalid percent sequence such as '/my%path/' or '/vite%/'.
Common situations: Passing a deployment prefix with a literal '%' (e.g. a versioned path), an unencoded query/fragment, or a copy-pasted URL with reserved characters.
Related errors
- `renderLegacyChunks` and `renderModernChunks` cannot be both
- Invalid environment name "${name}". Environment names must o
- `input` cannot contain glob characters. They are reserved, s
- Required environments configuration were stripped out in the
- Unsupported configLoader: ${configLoader}. Accepted values a
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/3254c4bfe863192d.json.
Report an issue: GitHub.