fix(core,tooling): keep the harness's own ports out of the Agent's environment and off the dev server (#100)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: J.Li <jl2388@cam.ac.uk>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Dev-server `/api` proxy target resolution (vite.config.ts). The interesting case is an
|
||||
* empty `PORT=`: shells export it, `.env` files carry it, and resolving it to a bare
|
||||
* `http://127.0.0.1:` sends every API call to port 80 without ever failing — a wrong backend
|
||||
* is far harder to notice than a broken one, so the empty case is pinned here.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { apiProxyTarget } from "../vite.config.js";
|
||||
|
||||
describe("apiProxyTarget", () => {
|
||||
it("defaults to the development backend, not the installed server's 7364", () => {
|
||||
expect(apiProxyTarget({})).toBe("http://127.0.0.1:7368");
|
||||
});
|
||||
|
||||
it("treats an empty PORT as unset rather than as port 80", () => {
|
||||
expect(apiProxyTarget({ PORT: "" })).toBe("http://127.0.0.1:7368");
|
||||
});
|
||||
|
||||
it("follows PORT so moving the backend moves the proxy with it", () => {
|
||||
expect(apiProxyTarget({ PORT: "9999" })).toBe("http://127.0.0.1:9999");
|
||||
});
|
||||
|
||||
it("PENGUIN_API_PROXY replaces the whole target, PORT and all", () => {
|
||||
expect(apiProxyTarget({ PORT: "9999", PENGUIN_API_PROXY: "http://10.0.0.2:8080" })).toBe(
|
||||
"http://10.0.0.2:8080",
|
||||
);
|
||||
});
|
||||
|
||||
it("an empty PENGUIN_API_PROXY falls back instead of proxying to nowhere", () => {
|
||||
expect(apiProxyTarget({ PENGUIN_API_PROXY: "" })).toBe("http://127.0.0.1:7368");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user