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);
        }
    );
2
  • 5
    You can find answers to this problem is you tried searching for one. Commented Jul 31, 2017 at 11:32
  • 1
    Cross origin requests are blocked by most browsers. If you use Chrome, look at this question: stackoverflow.com/questions/3102819/… Commented Jul 31, 2017 at 11:32

1 Answer 1

1

Cross Origin Requests should be allowed on server side.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.