I've got two separate apps (frontend and backend) running on heroku. Let's say frontend can be accessed through http://frontend-app.url
and backend through http://backend-app.url
The front end app runs on node.js
using express
. I want my frontend app to call backend app api, but I can't make it call anything other than the same domain that frontend is deployed.
In server.js
i got the following lines, which supposedly should reroute the api calls.
app.get('/data', (req, res) => {
res.json({url: 'http://backend-app.url'})
});
All api urls start with /data
. I start my app by node server.js
.
First call when accessing the frontend app is always /data/units
, but it always calls http://frontend-app.url/data/units
instead of http://backend-app.url/data/units
.
How do I make this right?