When I start my Angular 10 app locally with ng s -o
it works fine and it's able to connect to my backend, which is running on Heroku.
But when I deploy it on firebase it only displays the frontend parts and doesn't get the data from the backend anymore. The weird thing is that it tries to get the data from my local backend on localhost:8090
. But I replaced every localhost URL in my Angular App with the URL to my Heroku App:
When I run the Angular app locally on localhost:4200
I can see in the network analysis in the browser console that all http requests are made to the Heroku URL:
I saved all changes in my Angular folder where I changed the URLs from localhost to the Heroku URL, I then pushed everything to git (don't know if that makes a difference), then deleted the dist folder of my Angular App completely, then ran again ng build --prod
and firebase deploy
. But still, my on firebase deployed app on https://studileih-ceb70.web.app/ seems to keep making the request to https://localhost:8090/
instead of my Heroku URL ( https://studileih-heroku.herokuapp.com/ ). I used the search function of Visual Studio to see, if I forgot to replace a localhost URL in my project, but I replaced them all.
Additional info: When using the on firebase deployed app, the error appears for all http requests, not only for the one shown above for http://localhost:8090/products
: -> they should all be made to
https://studileih-heroku.herokuapp.com/
instead of localhost
.
Why does my deployed app still make requests to localhost
when I removed all localhost URLs from my app before building + deploying it?
Ok it seems that just running firebase deploy
wasn't enough, I also had to run firebase use --add
and give a new alias for the project before deploying it again. Then it worked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.