Angular relative paths in HTTP requests
Just prepend "./"
to the path you want to make relative
$http.post('./api/authenticate', { username: username, password: password });
The base URL for this HTTP AJAX request will be the domain address in the URL address bar in the browser.
For example:
Your application is running on https://example.com/user/profile
and when you execute:
$http.post('/api/authenticate', { username: username, password: password });
Then the browser will make an AJAX request to https://example.com/api/authenticate
You can get the base URL from browser using
var baseURL = window.location.protocol + '//' + window.location.host;
alert('Base URL for current frame is: ' + baseURL);