Sunday, 11 June 2017

$http.get requests with localhost address when deploying on cloud server

I have an AngularJS factory function like:

service.getUserRates = function() {
  return $http.get('https://localhost:8443/portfolio/get-user-rates');
}

This works fine on localhost, but before deploying on digital ocean servers I have to update the URL to include the IP address of the server - $http.get('http://67.205.xx.xxx:8443, instead of localhost or I get an ERR_CONNECTION_REFUSED error.

This is hard to manage since I am developing on local machine and pulling changes into cloud server, I have to keep changing the URL every time I do a new git push / pull.

What is the easiest / best way to manage this so I don't have to manually change the URLs repeatedly?



via chuckieDub

No comments:

Post a Comment