mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Convert absolute to relative selfLinks #1040

Open aeife opened 9 years ago

aeife commented 9 years ago

The api I'm using for my client is delivering absolute urls as a self link. That leads to some problems for local development and might also be a problem when deploying my application.

Is there a way to tell restangular to only use the path of the selfLinks even if they are absolute urls?

If not is there an efficient way I could implement this in my application? Using a responseInterceptor and setting the selfLinks manually may not work because I get lists and nested objects containing selfLinks. So finding all selfLinks manually and changing them might be not a good idea.

grabbou commented 9 years ago

Can you provide example data returned by your server and methods you are using (with comments where exactly wrong URL is invoked)? That'd be cool. Even cooler if you can wrap that in JSFiddle although not a requirement.

aeife commented 9 years ago

Thanks for your response. There actually is no wrong url invoked and this is also not a problem with restangular itself but more a missing feature I would like to see or maybe there is a solution to achive this.

To specify my issue this is an example server payload:

{
  id: 123,
  href: "http://example.virtual/api/v1"
}

So with such a payload restangular will correctly do calls against the href as self link. But it would be really cool if there was a feature so restangular would translate these self links to relative once like "/api/v1". This would help in local development where we have proxies to avoid cross domain requests.

grabbou commented 9 years ago

Ok, adding as a feature request for v2. Will try to play around wih that tomorrow to check how we can achieve that in v1. Thanks for detalied response.