fix(api): prevent 500 error in /api/config when siteConfig.hero is omitted

This commit is contained in:
Daniel S
2026-08-09 22:47:26 +02:00
parent 15b2a34957
commit 10d534e836

View File

@@ -17,11 +17,13 @@ export const POST: APIRoute = async ({ request }) => {
const newSite = {
...currentSite,
...body.siteConfig,
hero: { ...currentSite.hero, ...body.siteConfig.hero }
hero: { ...(currentSite.hero || {}), ...(body.siteConfig.hero || {}) },
site_info: { ...((currentSite as any).site_info || {}), ...(body.siteConfig.site_info || {}) }
};
fs.writeFileSync(path.join(dataDir, 'site.config.json'), JSON.stringify(newSite, null, 2), 'utf8');
}
if (body.themeConfig) {
const newTheme = { ...currentTheme, ...body.themeConfig };
fs.writeFileSync(path.join(dataDir, 'theme.config.json'), JSON.stringify(newTheme, null, 2), 'utf8');