withastro/astro · warning
Your "vercel.json" config is not a valid json file.
Error message
Your "vercel.json" config is not a valid json file.
What it means
The Vercel adapter reads vercel.json during build to compare its `trailingSlash` setting against Astro's and warn about conflicts that would cause redirect loops or duplicate content. If vercel.json exists but is not strict JSON (comments, trailing commas, syntax typos), the read throws, is caught here, and this warning is emitted. The trailingSlash conflict check is silently skipped and the adapter proceeds with defaults.
Source
Thrown at packages/integrations/vercel/src/index.ts:375
config.trailingSlash !== 'ignore' &&
existsSync(vercelConfigPath)
) {
try {
const vercelConfig = JSON.parse(readFileSync(vercelConfigPath, 'utf-8'));
if (
(vercelConfig.trailingSlash === true && config.trailingSlash === 'never') ||
(vercelConfig.trailingSlash === false && config.trailingSlash === 'always')
) {
logger.error(
`
Your "vercel.json" \`trailingSlash\` configuration (set to \`${vercelConfig.trailingSlash}\`) will conflict with your Astro \`trailingSlash\` configuration (set to \`${JSON.stringify(config.trailingSlash)}\`).
This would cause infinite redirects or duplicate content issues.
Please remove the \`trailingSlash\` configuration from your \`vercel.json\` file or Astro config.
`,
);
}
} catch (_err) {
logger.warn(`Your "vercel.json" config is not a valid json file.`);
}
}
setAdapter(
getAdapter({
buildOutput: _buildOutput,
middlewareMode: resolvedMiddlewareMode,
skewProtection,
staticHeaders: staticHeaders,
}),
);
} else {
setAdapter(
getAdapter({
middlewareMode: resolvedMiddlewareMode,
skewProtection,
buildOutput: _buildOutput,
staticHeaders: staticHeaders,
}),View on GitHub (pinned to 3578d45d34)
Solutions
- Make vercel.json strict JSON: remove comments and trailing commas
- Validate locally: `node -e "JSON.parse(require('fs').readFileSync('vercel.json','utf8'))"`
- Re-run the build — if you had a trailingSlash mismatch, you should now see the real conflict error
- Prefer configuring trailingSlash once in astro.config and removing it from vercel.json
Example fix
// before: vercel.json (invalid JSON)
{
// comment not allowed
"trailingSlash": true,
}
// after
{
"trailingSlash": true
} Defensive patterns
Strategy: validation
Validate before calling
// CI step: vercel.json must be strict JSON
import { readFileSync } from 'node:fs';
JSON.parse(readFileSync('vercel.json', 'utf8')); // throws on comments/trailing commas Prevention
- Never put comments or trailing commas in vercel.json
- Configure trailingSlash in one place only — preferably astro.config
- Add a JSON.parse lint for every config file the adapter reads
When it happens
Trigger: Running `astro build` with @astrojs/vercel while vercel.json contains JSONC syntax (comments, trailing commas) or a parse error.
Common situations: Hand-editing vercel.json and leaving a comment; JSONC habits from other config files; the trailingSlash conflict the check exists for then goes undetected.
Related errors
- Vercel Image Optimization requires at least one size to be c
- maxDuration must be a number
- Auto-generating collections for folders in "src/content/" t
- ${colors.bold(plugin)} not applied.
- ${colors.bold(plugin[0])} not applied.
AI-assisted analysis of withastro/astro@3578d45d34 (2026-08-18).
Data as JSON: /api/errors/4d34bf4bf35f1cd9.
Report an issue: GitHub.