feat(server): add regression test for handling empty request bodies

feat(terminal): focus terminal on click
fix(vite): update API proxy path to avoid frontend route conflicts
This commit is contained in:
catlog22
2026-02-25 09:59:54 +08:00
parent 6c16c121d2
commit 45c61186c4
4 changed files with 123 additions and 4 deletions

View File

@@ -114,7 +114,8 @@ function handlePostRequest(req: http.IncomingMessage, res: http.ServerResponse,
if (typeof cachedRawBody === 'string') {
try {
void handleBody(JSON.parse(cachedRawBody));
const trimmed = cachedRawBody.trim();
void handleBody(trimmed.length === 0 ? {} : JSON.parse(cachedRawBody));
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
res.writeHead(500, { 'Content-Type': 'application/json' });
@@ -128,7 +129,8 @@ function handlePostRequest(req: http.IncomingMessage, res: http.ServerResponse,
req.on('end', async () => {
try {
(req as any).__ccwRawBody = body;
const parsed = JSON.parse(body);
const trimmed = body.trim();
const parsed = trimmed.length === 0 ? {} : JSON.parse(body);
(req as any).body = parsed;
await handleBody(parsed);
} catch (error: unknown) {