I'm deploying my Angular application in a web server, where the app may live at http://localhost:8080/app-name, or http://foobars.com/, or some other URL. I do not have any guarantees about the absolute path - sometimes the call may need to go to /app-name/foo, sometimes to /foo, sometimes to /foobars/foo. In other words, there is a moving part: /app-name, (empty), /foobars in samples above. Also known as context path.
I know I can use <base> for HTML. I can wrap $http or configure Restangular to prepend context path for all calls.
But there still are cases that I don't yet know how to address. For instance, whenever directive uses a template, it is loaded via bare $http as well.
How can I get $http to always use some specific base path for all requests?