By jak6jak
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:
axios
.get(`http://localhost:3000/pollPage/fetchMovie/${query}`)
.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: https://github.com/jak6jak/movie-polling
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted 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:
https://www.digitalocean.com/docs/app-platform/how-to/use-environment-variables/
In your local environment, you can set the APP_URL to http://localhost:3000
.
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.