问题
i have setup the following proxies:
const app = require('express')();
const proxy = require('http-proxy-middleware');
app.use('/api', proxy({ target: 'https://swapi-graphql.netlify.com/.netlify/functions/index', changeOrigin: true}));
app.use('/image', proxy({ target: 'localhost:8000' , changeOrigin: true}));
app.listen(8080);
The /api route proxies normally but the /image proxy returns the following error :
[HPM] Error occurred while trying to proxy request /image from localhost:8080 to localhost:8000 (ENOTFOUND) (https://nodejs.org/api/errors.html#errors_common_system_errors)
The issue is not in my image api because when i post directly to the /image route, the issue doesnt happen. Only when i do it via port 8080.
What I tried:
Changing the port -> didnt work
来源:https://stackoverflow.com/questions/60227022/how-to-solve-error-while-proxying-to-api-in-localhost