What should I change localhost:3000 axios requests to when deployed?

Posted February 4, 2021 5.4k views
Node.jsDeploymentDigitalOcean App Platform

I’m having trouble with figuring out how to access my express api. On my local development machine I had no trouble accessing it with axios requests for example:

        .then((response) => {

however now that my app is deployed these requests do not work anymore they give me 404 errors. what should I change these requests to so that my app is able to function again? If you want to know how my application is setup here is the github link:

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @jak6jak,

What you could do is set up a base URL

axios.defaults.baseURL = process.env.APP_URL

Then you could use the DigitalOcean App env variables to pass the APP_URL to your application:

In your local environment, you can set the APP_URL to http://localhost:3000.

Let me know how it goes!