restangular icon indicating copy to clipboard operation
restangular copied to clipboard

url in Restangular api calls needs application context name unlike $http

Open chetanpadhye opened this issue 10 years ago • 1 comments

url in call needs application context name unlike $http. Application context name may change and keeping it hard coded in url is not handy. This is because '/' get prepended to url in Path.prototype.base function acum.replace(//$/, "") + "/" + elemUrl;

We should add "/" only if this.config.baseUrl is not empty and it is not ending with '/' else keep url intact as it is passed to make XMLHttp request.

chetanpadhye avatar Apr 29 '15 07:04 chetanpadhye

This sounds like exactly the issue I'm running into myself. Did you ever come up with anything?

Here is the explanation of what I'm seeing.

I have an app running at example.com/app-name. I have a call to an endpoint like Restangular.all('foo').post(data); of which I expect it to hit example.com/app-name/foo but I'm seeing it hit example.com/foo instead, which gives a 404. I thought I would hardcode the context like Restangular.setBaseUrl('app-name') and deal with it later but in testing after that it now hits example.com/app-name/app-name/foo. So it appears to strip the context off in one instance but then use it in the next.

greeny88 avatar Dec 19 '16 22:12 greeny88