So I would like to find a way how to implement this part of package.json to my server.js which is responsible for my React App server side rendering.
"proxy": {
"/api/*": {
"target": "http://localhost:3501"
},
"/media/*": {
"target": "http://localhost:3501"
}
},
I have looked into some of the libraries like express-http-proxy and http-proxy-middleware but I cannot find a working solution.
Last I tried:
import proxy from 'express-http-proxy';
...
app.use('/api', proxy('http://localhost:3501/api/*'));
app.use('/media', proxy('http://localhost:3501/media/*'));
It logs 404 and the path is basically right, just without "/api/" should be "/api/posts/" but logs only "/posts/".