Open KozyWorks opened 1 year ago
Any 1 ever figure this out?
This worked for us using CRA@5 and HPM@3.
const proxy = createProxyMiddleware({
target: 'http://localhost:3001',
changeOrigin: true,
pathFilter: '/api',
});
module.exports = (app) => app.use(proxy);
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
As a part of my React (front) / Express (backend) project, I have a web crawler that crawls buffer, decodes then obtain desired data using cheerio.
(Just to clarify, I am not using any data obtained for commercial use, but only for a personal project.)
server.js:
Then I have setup a proxy using http-proxy-middleware on front-end.
setupProxy.js:
Articles.js:
So, this actually works and fetches data as I expected, but then when the server is left running idle, doing nothing, the client fails to fetch data from the server on page refresh (or maybe on a new session) and spits the long, long error below:
It just feels like the client loses the connection to the server via proxy.
Here's the things I've tried:
connection: "keep-alive"
option tocreateProxyMiddleware
headerfetch
fromaxios
/api/naver/cafe/${props.menu.id}
→http://localhost:3000/api/naver/cafe/${props.menu.id}
)and nothing really resolved the issue.
The only way to fix this error is either by refreshing the page until it works or restarting the server.
I do have some Twitch's helix related apis as well, but this error only occurs with the crawling function above.
Literally spent hours and hours to troubleshoot this... and failed.
Any ideas, please?
I am using NodeJS v18.10.0 btw.
Step-by-step reproduction instructions
Expected behavior (be clear and concise)
Fetch data from server with no issue
How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
No response