Fix harness forbidden error: use internal token instead of host check
The localhost check using host header and x-forwarded-for was unreliable in the standalone Next.js server which may inject forwarded headers internally. Replace with a per-process random token shared between the PTY server and the API route via env var.
This commit is contained in:
@@ -53,6 +53,7 @@ function attachPtyWebSocket(server) {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`http://127.0.0.1:${port}/api/agents/${encodeURIComponent(agentId)}/env`,
|
||||
{ headers: { "x-internal-token": process.env.INTERNAL_API_TOKEN || "" } },
|
||||
);
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
|
||||
Reference in New Issue
Block a user