Skip to content

Commit b35f691

Browse files
committed
fix(oauth-proxy): inject META_ACCESS_TOKEN as Bearer for backend AuthInjectionMiddleware
Upstream security fix GHSA-9gw6-46qc-99vr added AuthInjectionMiddleware that hard-rejects requests without an Authorization header. The proxy was stripping the header before forwarding, causing 401 on every claude.ai request. Now injects META_ACCESS_TOKEN as the Bearer token the backend expects.
1 parent 088a80e commit b35f691

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎oauth-proxy.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const BACKEND_PORT = parseInt(process.env.BACKEND_PORT || "8081", 10);
77
const AUTH_TOKEN = (process.env.MCP_AUTH_TOKEN || "").trim();
88
const OAUTH_CLIENT_ID = (process.env.OAUTH_CLIENT_ID || "").trim();
99
const OAUTH_CLIENT_SECRET = (process.env.OAUTH_CLIENT_SECRET || "").trim();
10+
const META_ACCESS_TOKEN = (process.env.META_ACCESS_TOKEN || "").trim();
1011

1112
const authCodes = {};
1213

@@ -42,7 +43,14 @@ function proxy(req, res, bodyBuf) {
4243
// not the upstream MCP) and force the host header to localhost so upstream
4344
// host checks accept the proxied request.
4445
const headers = { ...req.headers, host: "localhost:" + BACKEND_PORT };
45-
delete headers["authorization"];
46+
// Replace the MCP auth token (used to authenticate to this proxy) with the
47+
// Meta access token so the backend's AuthInjectionMiddleware accepts the
48+
// request and uses it for Meta API calls.
49+
if (META_ACCESS_TOKEN) {
50+
headers["authorization"] = "Bearer " + META_ACCESS_TOKEN;
51+
} else {
52+
delete headers["authorization"];
53+
}
4654
delete headers["content-length"];
4755
if (bodyBuf) headers["content-length"] = bodyBuf.length;
4856
const proxyReq = http.request(

0 commit comments

Comments
 (0)