Reputation: 12468
I am using $http.get with a relative url like this:
$http.get('/api/product')
.then(function (res) { });
The resultant call is:
GET http://localhost/api/product 404 (Not Found)
Now the problem is my site is running in IIS under a virtual directory, the structure is like this:
Sites
- Default Web Site
- Website (Virtual Directory)
- Services (Virtual Directory)
So the URL I actually want AngularJs to call is:
GET http://localhost/website/api/product
I have tried setting the BASE element like this:
<base href="Website/">
(And using http://localhost/website/
)
But nothing seems to correct the URL?
What can I do? I would still like to use the relative URL with angularjs.
Upvotes: 1
Views: 156
Reputation: 559
Change from
$http.get('/api/product').then(function (res) { });to
$http.get('/website/api/product').then(function (res) { });
Upvotes: 1
Reputation: 5058
Try this: $http.get('api/product')
.then(function (res) { });
Upvotes: 1