{"record":{"id":"ca0adaf7cbc38fc3","repo":"microsoft/aspire","slug":"unexpected-vite-config-format-falling-back-to-original","errorCode":null,"errorMessage":"Unexpected Vite config format. Falling back to original configuration without Aspire HTTPS modifications.","messagePattern":"Unexpected Vite config format\\. Falling back to original configuration without Aspire HTTPS modifications\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs","lineNumber":109,"sourceCode":"        server: {\n            ...innerConfig.server,\n            https: innerConfig.server?.https ?? aspireHttpsConfig,\n        }\n    })\n\n    let finalConfig = config\n    try {\n        if (typeof config === 'function') {\n            finalConfig = defineConfig((cfg) => {\n                let innerConfig = config(cfg)\n\n                return wrapConfig(innerConfig)\n            });\n        } else if (typeof config === 'object' && config !== null) {\n            let innerConfig = config\n            finalConfig = defineConfig(wrapConfig(innerConfig))\n        } else {\n            console.warn('Unexpected Vite config format. Falling back to original configuration without Aspire HTTPS modifications.')\n            finalConfig = config\n        }\n    } catch {\n        console.warn('Error applying Aspire Vite configuration. Falling back to original configuration without Aspire HTTPS modifications.')\n        finalConfig = config\n    }\n\n    export default finalConfig\n    \"\"\";\n\n    /// <summary>\n    /// Adds a node application to the application model. Node should be available on the PATH.\n    /// </summary>\n    /// <param name=\"builder\">The <see cref=\"IDistributedApplicationBuilder\"/> to add the resource to.</param>\n    /// <param name=\"name\">The name of the resource.</param>\n    /// <param name=\"appDirectory\">The path to the directory containing the node application.</param>\n    /// <param name=\"scriptPath\">The path to the script relative to the app directory to run.</param>\n    /// <returns>A reference to the <see cref=\"IResourceBuilder{T}\"/>.</returns>","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L91-L127","documentation":"Aspire's JavaScript hosting injects HTTPS development-certificate configuration into a project's vite.config by wrapping the exported config. When the generated script sees a vite.config default export whose shape is neither a function nor a plain object (e.g. defineConfig returned something unexpected, or an array form), it logs this console.warn and falls back to the original config untouched — meaning the Aspire HTTPS modifications are NOT applied.","triggerScenarios":"addNpm/Vite app integration rewrites vite.config.* and evaluates the existing default export; the export is not a function and not a non-null object (primitive, null, or unusual defineConfig output), so the else branch warns and uses the config as-is.","commonSituations":"Hand-edited vite.config exporting an unsupported shape; older Vite templates or plugins altering the export; projects where 'defineConfig' is wrapped or re-exported in a way Aspire's wrapper does not recognize.","solutions":["Restructure vite.config so the default export is either a plain config object or a function returning the config — the two shapes Aspire recognizes.","Verify no custom wrapper around defineConfig changes the exported value's type.","If HTTPS config is intentionally handled elsewhere, the warning can be ignored, but confirm browser dev-server URLs still work with the AppHost endpoints.","Update Vite/project templates if an outdated template produces the odd export shape."],"exampleFix":"// before: exotic export shape\nexport default [...(somePluginConfig), defineConfig({ server: {} })];\n// after: plain object (or function) export\nexport default defineConfig({ server: { /* ... */ } });","handlingStrategy":"validation","validationCode":"// Validate the vite config default export shape before Aspire processes it.\nimport cfg from './vite.config';\nconst isFn = typeof cfg === 'function';\nconst isObj = typeof cfg === 'object' && cfg !== null && !Array.isArray(cfg);\nif (!isFn && !isObj) throw new TypeError('vite.config default export must be a function or object');","typeGuard":"function isSupportedViteConfig(cfg) {\n  return typeof cfg === 'function' || (typeof cfg === 'object' && cfg !== null);\n}","tryCatchPattern":"// Since the injector only warns and falls back, watch for it in build output:\nprocess.on('warning', () => {}); // or grep dev-server output for:\n// 'Unexpected Vite config format' -> fix vite.config export shape","preventionTips":["Keep vite.config's default export a plain object or a function returning the config.","Avoid exotic re-exports/wrappers around defineConfig in templates.","After Aspire modifies the config, verify HTTPS dev URLs actually work to confirm the modifications applied."],"tags":["vite","javascript","config","https"],"backgroundTag":"unsupported-config-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}