Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global configuring $http for using CORS in angularJS (fixed domain for all requests)

I have ad restful server and a web server in another domain for serving asset files.

In past both of this servers was same and serves in one server. and now I try to change the relative URLs to Explicit one.

Ordinary solution is changing all used URLs like this:

$http.post(DATA_SERVER_DOMAIN+"/service/method" )

instead of

$http.post("/service/method" )

is there any solution to set fixed domain for all $http or $resource requests in angularJS (for example in $httpprovider)

like image 915
Mohsen Kashi Avatar asked Nov 10 '22 01:11

Mohsen Kashi


1 Answers

I really suggest using the Restangular Library if you want functionality like this and a better coding experience.

It allows you to set different base urls for each service you create.

Reference.

While this may not be exactly what you're looking for at the moment, you'll be happy you took my advice.

like image 56
Stone Avatar answered Nov 14 '22 21:11

Stone