Skip to content

Commit

Permalink
Adjust proxy for Node.js v18
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 19, 2024
1 parent cbff973 commit d76e0da
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions timgen/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,47 @@ const onProxyRes = (proxyRes, req, res) => {
}

const httpProxyMiddleware = createProxyMiddleware({
// agent: new http.Agent({
// // see https://github.com/LayerManager/layman/issues/755
// secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
// }),
router: proxyRouter,
pathRewrite,
onProxyReq: (proxyReq, req, res) => {
const full_url = proxyReq.protocol + '//' + proxyReq.host + proxyReq.path;
const headers = proxyReq.getHeaders();
// proxyReq.agent = new http.Agent({
// // see https://github.com/LayerManager/layman/issues/755
// secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
// });
console.log(`onProxyReq, full_url=${full_url}, headers=${JSON.stringify(headers, null, 2)}`)
},
onProxyRes: onProxyRes,
changeOrigin: true,
secure: false,
// logLevel: "debug",
logLevel: "debug",
});

const httpsProxyMiddleware = createProxyMiddleware({
agent: new https.Agent({
// see https://github.com/LayerManager/layman/issues/755
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
}),
router: proxyRouter,
pathRewrite,
onProxyReq: (proxyReq, req, res) => {
const full_url = proxyReq.protocol + '//' + proxyReq.host + proxyReq.path;
const headers = proxyReq.getHeaders();
proxyReq.agent = new https.Agent({
// see https://github.com/LayerManager/layman/issues/755
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
});
// proxyReq.agent = new https.Agent({
// // see https://github.com/LayerManager/layman/issues/755
// secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
// });
console.log(`onProxyReq, full_url=${full_url}, headers=${JSON.stringify(headers, null, 2)}`)
},
onProxyRes: onProxyRes,
changeOrigin: true,
secure: false,
// logLevel: "debug",
logLevel: "debug",
});

app.use("/http_proxy", httpProxyMiddleware);
Expand Down

0 comments on commit d76e0da

Please sign in to comment.