I am deploying Node and React app on Heroku at the same server, I have set up my Axios in React with base URL like this:
export default axios.create({
baseURL: `http://localhost:5001/api`,
withCredentials: true,
headers: {
"Content-type": "application/json",
},
});
Because Heroku creates a dynamic port for my Node app, this is not working to make request. Is there is any way I can read the port generated by Heroku and use it my React app?
CodePudding user response:
If your app is deployed on heroku, why are you trying to use a url including localhost instead of the url of your app that heroku provides you?
Anyway, I think you can retrieve the port that heroku is using with process.env.PORT