{"record":{"id":"961029745f6156c4","repo":"sveltejs/kit","slug":"options-request-handlers-will-not-work-unless-k","errorCode":null,"errorMessage":"OPTIONS request handlers will not work unless `${key}.preflightContinue` is set to `true`","messagePattern":"OPTIONS request handlers will not work unless `(.+?)\\.preflightContinue` is set to `true`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/exports/vite/index.js","lineNumber":69,"sourceCode":" * @returns {CorsOptions | undefined}\n */\nfunction resolve_cors(user_cors, key, warn) {\n\t// `preview.cors` falls back to the resolved `server.cors`, so emitting a value here when\n\t// the user hasn't set one is what drops Vite's `defaultAllowedOrigins` restriction\n\tif (user_cors === undefined) {\n\t\treturn key === 'server.cors' ? { preflightContinue: true } : undefined;\n\t}\n\n\t// with `cors: false` Vite installs no CORS middleware, so OPTIONS handlers already work\n\tif (user_cors === false) return undefined;\n\n\tif (typeof user_cors === 'object' && user_cors !== null) {\n\t\tif (user_cors.preflightContinue === undefined) return { preflightContinue: true };\n\t\tif (user_cors.preflightContinue) return undefined;\n\t}\n\n\tif (warn) {\n\t\tconsole.warn(\n\t\t\tstyleText(\n\t\t\t\t['yellow', 'bold'],\n\t\t\t\t`OPTIONS request handlers will not work unless \\`${key}.preflightContinue\\` is set to \\`true\\``\n\t\t\t)\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\nconst removed_modules = [\n\t{\n\t\tname: '$lib',\n\t\tpattern: /^\\$lib(?:\\/.*|\\?.*)?$/,\n\t\tmessage:\n\t\t\t\"`$lib` has been removed. Use `#lib` instead: https://svelte.dev/docs/kit/$lib. To keep using `$lib`, add `alias: { '$lib': 'src/lib' }` to your SvelteKit config.\"\n\t},\n\t{","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/vite/index.js#L51-L87","documentation":"resolve_cors in the Vite plugin computes the effective `server.cors`/`preview.cors` setting. When the user supplied a cors object without `preflightContinue`, OPTIONS requests are consumed by Vite and SvelteKit's `OPTIONS` route handlers will never fire; this warning tells you to set `preflightContinue: true` (SvelteKit already defaults it when cors is left unset).","triggerScenarios":"Setting `server.cors` (or `preview.cors`) to an object like `{ origin: true }` in vite.config without `preflightContinue`, while the app defines `export async function OPTIONS()` handlers.","commonSituations":"Adding CORS config for an external dev origin; following generic Vite CORS guides while also having SvelteKit route handlers for OPTIONS.","solutions":["Set `cors: { preflightContinue: true, ... }` under `server` (and `preview` if needed) in vite.config.js","Remove the explicit cors object entirely so SvelteKit's default (`preflightContinue: true`) applies","Only if you don't use OPTIONS handlers, set `preflightContinue: false` knowingly to silence it"],"exampleFix":"// before (vite.config.js)\nexport default { server: { cors: { origin: 'https://app.dev' } } };\n// after\nexport default { server: { cors: { origin: 'https://app.dev', preflightContinue: true } } };","handlingStrategy":"validation","validationCode":"// validate vite config before dev\nconst cors = config.server?.cors;\nif (typeof cors === 'object' && cors !== null && cors.preflightContinue === undefined) {\n  console.warn('set server.cors.preflightContinue = true for OPTIONS handlers');\n}","typeGuard":"const needsPreflightContinue = (cors) => typeof cors === 'object' && cors !== null && cors.preflightContinue === undefined;","tryCatchPattern":null,"preventionTips":["Prefer omitting `cors` entirely and let SvelteKit defaults apply","Document any custom cors objects in the repo and include preflightContinue","Smoke-test OPTIONS routes with curl after touching vite.config"],"tags":["cors","vite","preflight"],"backgroundTag":"cors-preflight-configuration","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}