fix: harden workflow console runtime

This commit is contained in:
lda
2026-07-02 17:35:16 +07:00 Verified
parent bcf31583af
commit ea1276badd
22 changed files with 684 additions and 128 deletions
+27 -1
View File
@@ -1,12 +1,38 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
const backendPort = process.env.WEB_PORT ?? "8787";
export default defineConfig({
plugins: [react()],
server: {
proxy: {
// Server must listen on this port (set via WEB_PORT env or default 8787)
"/api": "http://127.0.0.1:8787",
"/api": {
target: `http://127.0.0.1:${backendPort}`,
configure: (proxy) => {
proxy.on("error", (error, _request, response) => {
if (response.headersSent) return;
const detail =
error instanceof Error ? ` (${error.message})` : "";
response.writeHead(502, {
"content-type": "application/json",
});
response.end(
JSON.stringify({
ok: false,
error: {
code: "console_backend_unreachable",
message:
`Console backend unavailable at 127.0.0.1:${backendPort}. ` +
`Restart pnpm --dir web dev.${detail}`,
},
exchange: { request: null, response: null },
}),
);
});
},
},
},
},
test: {