我收到此错误:
XMLHttpRequest无法加载http://example.com/user/api?action=user_info。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许原点“http://192.168.1.122:8100”访问。
我有adde代理网址,如下所示:
{
"name": "conference",
"app_id": "",
"proxies": [
{
"path": "/api",
"proxyUrl": "http://example.com/user/api"
}
]
}
致电api:
$http({
method: 'POST',
url: 'http://example.com/user/api?action=user_info',
headers: {'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(data, status) {
console.log('Got some data: ', data);
}).error(function(data, status) {
console.log('Got some error: ', data);
console.log('Got some error: ', status);
});
答案 0 :(得分:1)
没有错:
删除完整网址,如下面的代码所示:
$http({
method: 'POST',
url: '/api?action=login',
headers: {'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(data, status) {
console.log('Got some data: ', data);
}).error(function(data, status) {
console.log('Got some error: ', data);
console.log('Got some error: ', status);
});