Open mylnikovD opened 4 years ago
I get the same [HPM] Error occurred while trying to proxy request ... (ENOTFOUND)
with WireGuard VPN. Target is reachable in browser.
me too
I get similar error when requesting my proxy server (node.js v14.15.1 + express):
Error occured while trying to proxy to: <hostname>
Response code: 500.
Here is my code:
app.use('/api', createProxyMiddleware({
target: API_SERVICE_URL,
pathRewrite: {
[`^/api`]: '',
},
}));
у меня такая же проблема next.js + express
server.use(
'/auth-api',
createProxyMiddleware({
target: CURRENT_API_URL,
changeOrigin: true,
logLevel: 'debug',
pathRewrite: {
'^/auth-api': '/',
},
}),
);
Is there any update on this? I got the same behavior on MacOS. I am using ClashX as my VPN and config it to be system level proxy but still cannot get it working. My guess is somehow the lower level of http-proxy-middleware ignores VPN so that all the requests got timeout at last.
I found a way to solve this problem. https://stackoverflow.com/questions/41832770/node-http-proxy-not-working-behind-proxy
Hope this helps someone.
me too. It worked fine even log error.
It worked for me using v2ray protocol on a mac with V2rayU. Just set the http listen address and port as an agent like bellow and you're good to go:
var HttpsProxyAgent = require('https-proxy-agent');
const { createProxyMiddleware, fixRequestBody } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: process.env.REACT_APP_API_URL
changeOrigin: true,
secure: false,
logLevel: "debug",
onProxyReq: fixRequestBody,
agent: new HttpsProxyAgent('http://127.0.0.1:1087'),
headers: {
'X-Auth-Token': process.env.REACT_APP_API_TOKEN
},
pathRewrite: {
'^/api': ''
}
})
);
};
In the latest version, you need to use curly braces when importing, like this:
const { HttpsProxyAgent } = require('https-proxy-agent');
Hello, I'm using react app on localhost:3000 which is proxying to our backend server via OpenConnect vpn. My setup is on windows machine and everything worked fine until some moment when I was doing
npm start
I've started getting"[HPM] Error occurred while trying to proxy request ... (ENOTFOUND)" errors. The strange things started here - the backend is reachable and opens without any problem in browser, and restarting my PC is actually helping me to solve this problem, however, reloading PC on every occurrence of this error seems snot very good :)
My guess it's something with windows settings, or maybe with VPN connections in the system, I thought maybe someone encountered with the same thing and can give me a hint