sveltejs/kit · error · Error
You must remove all `site` keys in ${config_path}. Consult h
Error message
You must remove all `site` keys in ${config_path}. Consult https://svelte.dev/docs/kit/adapter-cloudflare#Migrating-from-Workers-Sites What it means
adapter-cloudflare no longer supports Cloudflare Workers Sites (the legacy `site` config that uploads a static asset directory via KV). The adapter validates the wrangler config at build time and refuses to proceed when any `site` key is present, directing you to migrate to Workers Static Assets (`assets.directory`).
Source
Thrown at packages/adapter-cloudflare/utils.js:27
return true;
}
if (!!process.env.WORKERS_CI || wrangler_config.main || wrangler_config.assets) {
return false;
}
return true;
}
/**
* @param {import('wrangler').Unstable_Config} wrangler_config
*/
export function validate_worker_settings(wrangler_config) {
const config_path = wrangler_config.configPath || 'your wrangler.jsonc file';
// we don't support workers sites
if (wrangler_config.site) {
throw new Error(
`You must remove all \`site\` keys in ${config_path}. Consult https://svelte.dev/docs/kit/adapter-cloudflare#Migrating-from-Workers-Sites`
);
}
// we need the `assets.directory` key so that the static assets are deployed
if ((wrangler_config.main || wrangler_config.assets) && !wrangler_config.assets?.directory) {
throw new Error(
`You must specify the \`assets.directory\` key in ${config_path}. Consult https://developers.cloudflare.com/workers/static-assets/binding/#directory`
);
}
// we need the `assets.binding` key so that the Worker can access the static assets
if (wrangler_config.main && !wrangler_config.assets?.binding) {
throw new Error(
`You must specify the \`assets.binding\` key in ${config_path} before deploying your Worker. Consult https://developers.cloudflare.com/workers/static-assets/binding/#binding`
);
}
View on GitHub (pinned to 03f1687fe6)
Solutions
- Delete the `site` block (and any `[site]` section in wrangler.toml) from your wrangler config.
- Add an `assets.directory` key pointing at the built client assets (the adapter usually does this automatically).
- Follow the migration guide at https://svelte.dev/docs/kit/adapter-cloudflare#Migrating-from-Workers-Sites.
- If you intentionally need Workers Sites, stay on an older adapter version (not recommended).
Example fix
// before (wrangler.jsonc)
{
"name": "my-app",
"site": { "bucket": "./public" }
}
// after
{
"name": "my-app",
"assets": { "directory": ".svelte-kit/cloudflare" }
} Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
const cfg = JSON.parse(fs.readFileSync('wrangler.jsonc', 'utf8'));
if (cfg.site) throw new Error('Remove all `site` keys from wrangler.jsonc before building with adapter-cloudflare'); Type guard
function isSitesConfig(config) {
return config != null && typeof config === 'object' && 'site' in config;
} Try / catch
try {
await build();
} catch (e) {
if (String(e).includes('`site` keys')) {
console.error('Migrate from Workers Sites: remove `site`, add `assets.directory`');
process.exit(1);
}
throw e;
} Prevention
- Search wrangler.jsonc/wrangler.toml for `site` after upgrading adapter versions.
- Follow the adapter-cloudflare migration guide when coming from Workers Sites templates.
- Let `vite build` generate the assets config rather than copying legacy configs.
- Pin and read adapter changelogs for breaking config changes.
When it happens
Trigger: Running `vite build` (the adapter's adapt step) with a wrangler.jsonc/wrangler.toml that still contains a `site` block (site.bucket, site.include, etc.).
Common situations: Projects upgraded from older adapter versions or migrated from a template based on Workers Sites; copying an old wrangler.toml from a non-SvelteKit Sites project.
Related errors
- You must specify the `assets.directory` key in ${config_path
- You must specify the `assets.binding` key in ${config_path}
- You must specify the `main` key in ${config_path} if you wan
- The following _redirects rule cannot be excluded by _routes.
- routes.include and routes.exclude must be arrays
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/aa871c0a8773019b.
Report an issue: GitHub.