I am facing a problem here trying to proxy all requests through a new machine private_ip but i get ENOTFOUND on the ip:
app.use(async (req, res, next) => {
try {
const { ip, id } = await newMachine();
const proxyMiddleware = createProxyMiddleware({
target: `http://${ip}:80`,
changeOrigin: true,
onError: async (err, req, res) => {
console.error("An error occurred while proxying the request:", err);
await killMachine(id);
res.status(500).json({
message: "An error occurred while proxying the request.",
error: err,
});
},
onProxyRes: async (proxyRes, req, res) => {
await killMachine(id);
console.log(`Request to ${req.url} was successfully proxied.`);
},
});
proxyMiddleware(req, res, next);
} catch (error) {
console.error("Error creating a new machine:", error.message);
res.status(500).json({ message: "Error creating a new machine.", error });
}
});