fix(remote-control): send utf-8 charset for plain text errors

This commit is contained in:
Yejun Su 2026-03-20 20:12:47 +08:00
parent 9821efa370
commit 63a879046b
No known key found for this signature in database
GPG Key ID: AD03A563F321CA44
1 changed files with 2 additions and 2 deletions

View File

@ -97,7 +97,7 @@ export function startServer(pi: ExtensionAPI, ctx: ExtensionContext): Promise<Re
const hasValidToken = providedToken && validateToken(providedToken, token); const hasValidToken = providedToken && validateToken(providedToken, token);
if (!hasValidSession && !hasValidToken) { if (!hasValidSession && !hasValidToken) {
res.writeHead(403, { "Content-Type": "text/plain" }); res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
res.end("Forbidden — valid token required. Use the URL shown in the pi terminal."); res.end("Forbidden — valid token required. Use the URL shown in the pi terminal.");
return; return;
} }
@ -127,7 +127,7 @@ export function startServer(pi: ExtensionAPI, ctx: ExtensionContext): Promise<Re
}); });
res.end(buildHTML(nonce)); res.end(buildHTML(nonce));
} else { } else {
res.writeHead(404, { "Content-Type": "text/plain" }); res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
res.end("Not found"); res.end("Not found");
} }
}); });