1

I am getting this error:

XMLHttpRequest cannot load http://example.com/user/api?action=user_info. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.122:8100' is therefore not allowed access.

I have adde proxy url as show below:

{
    "name": "conference",
    "app_id": "",
    "proxies": [
                {
                    "path": "/api",
                    "proxyUrl": "http://example.com/user/api"
                }
            ]
}

Calling 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);
});

1 Answer 1

1

There is little mistake:

remove full url as show in below code:

$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);
  });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.