我已經使用spring mvc編寫了REST API,它託管在一個域上,而前端使用HTML和角色JS編寫,並託管在另一個域上。現在,我想從另一個放置Frond UI的域調用REST API,那麼如何使用相對URI而不是絕對URI調用REST API?從不同的域調用REST API,例如相對URL的angular JS
對於
webbrokerModule.factory('CustomerContact', [ '$resource', function($resource) {
return $resource('http://localhost:24000/webbroker/customercontact/:brokerid', {
brokerid : '@brokerid'
}, {
get : {
method : 'GET'
}
});
} ]);
I want to call it as
webbrokerModule.factory('CustomerContact', [ '$resource', function($resource) {
return $resource('/webbroker/customercontact/:brokerid', {
brokerid : '@brokerid'
}, {
get : {
method : 'GET'
}
});
} ]);
我不想提IP地址和端口e.g.Instaed。
檢查回答 https://stackoverflow.com/questions/18984518/angularjs-globally-modify-the-url-of-every-request-in-http – BotanMan