Allow the safe-chain to act as a regular http proxy too (besides the CONNECT tunneling implementation)

This commit is contained in:
Sander Declerck 2025-10-13 15:49:42 +02:00
parent 5eedbfb57f
commit 8ed2330a3c
No known key found for this signature in database
2 changed files with 60 additions and 7 deletions

View file

@ -1,6 +1,7 @@
import * as http from "http";
import { tunnelRequest } from "./tunnelRequestHandler.js";
import { mitmConnect } from "./mitmRequestHandler.js";
import { handleHttpProxyRequest } from "./plainHttpProxy.js";
import { getCaCertPath } from "./certUtils.js";
import { auditChanges } from "../scanning/audit/index.js";
import { knownRegistries, parsePackageFromUrl } from "./parsePackageFromUrl.js";
@ -54,13 +55,7 @@ export function mergeSafeChainProxyEnvironmentVariables(env) {
}
function createProxyServer() {
const server = http.createServer((_, res) => {
res.writeHead(400, "Bad Request");
res.write(
"Safe-chain proxy: Direct http not supported. Only CONNECT requests are allowed."
);
res.end();
});
const server = http.createServer(handleHttpProxyRequest);
return server;
}