Retreving current domain in Angular model (angular service where ajax calls reside) to prepare full api url to retrieve data Retreving current domain in Angular model (angular service where ajax calls reside) to prepare full api url to retrieve data angularjs angularjs

Retreving current domain in Angular model (angular service where ajax calls reside) to prepare full api url to retrieve data


You can use the $location service for that.

$log.info($location.absUrl());$log.info($location.protocol() + "://" + $location.host() + ":" + $location.port());

But if you use relative URLs starting with a '/' to access your back-end, you should also get the behavior you want.