Reputation: 141
when I use axios on localhost I use it like this axios.post('http://localhost:5000/action', { data: data })
but it doesn't works on heroku, what should I replace localhost:5000 with? Axios is called from the client app.
Upvotes: 1
Views: 2246
Reputation: 13966
Making two deployements is the most used solution for project, in one part your frontend that will fetch the data from a remote api which is your backend and second deploy.
You will have to change your baseURL to app_name.herokuapp.com Also you will probably will have to enable CORS. Heroku sets it's own ports so you will need to create a .env file and assign it via ssh or manually in the Heroku dashboard.
Upvotes: 1
Reputation: 8102
No you're doing it wrong as it is no more your local machine. Heroku gives youר application a default domain: [name of app].herokuapp.com, use it.
Upvotes: 2