0

I am developing an application on angular and I am new to it.

Here is my requirement, I am trying to get the data using http post. But it is giving below error. XMLHttpRequest cannot load http://162.12.0.117:8081/Server/config/getAllConfigurationValues. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

Below is the my code.

    let headers = new Headers({ 'Content-Type': 'application/json'});

    let options = new RequestOptions({ headers: headers });
    this.http.post(
    "http://162.12.0.117:8081/Server/config/getAllConfigurationValues", 
    {
        "userName": "username",
        "password": "password"
    },
    options
    ).subscribe(
        (result) => function(){
            console.log(result);
        }
    );
  • 5
    You can find answers to this problem is you tried searching for one. – Reactgular Jul 31 '17 at 11:32
  • 1
    Cross origin requests are blocked by most browsers. If you use Chrome, look at this question: https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome – JSON Derulo Jul 31 '17 at 11:32

1 Answers1

1

Cross Origin Requests should be allowed on server side.