diff --git a/packages/core/src/webui/server.ts b/packages/core/src/webui/server.ts index 39a60772..2fd59d3f 100644 --- a/packages/core/src/webui/server.ts +++ b/packages/core/src/webui/server.ts @@ -551,6 +551,12 @@ export async function initWebUI( app.get('/api/ui/public', (c) => c.json({ appearance: publicAppearance() })); app.post('/api/ui', async (c) => { + // Reject oversized bodies before buffering — the normalizer caps individual + // fields (customCss 50KB, per-widget config 4KB) but not the whole payload. + const declaredLen = Number(c.req.header('content-length')); + if (Number.isFinite(declaredLen) && declaredLen > 256 * 1024) { + return c.json({ success: false, message: '配置过大' }, 413); + } let body: unknown; try { body = await c.req.json(); diff --git a/packages/core/src/webui/ui-config.ts b/packages/core/src/webui/ui-config.ts index c646f12d..0fdc817f 100644 --- a/packages/core/src/webui/ui-config.ts +++ b/packages/core/src/webui/ui-config.ts @@ -87,6 +87,13 @@ export interface UiAppearance { timeFormat: TimeFormat; /** Dashboard poll interval (ms); 0 = paused. */ pollInterval: number; + /** + * Operator custom CSS, applied AFTER auth only (never on the login page — + * `publicAppearance` strips it). Capped at 50 KB. The client injects it as + * the last