I'm making a POST request from a browser to my EC2 AWS server but getting the following error back.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.example.com' is therefore not allowed access. The response had HTTP status code 401.
I've done some research and release I need to enable CORS on my EC2 AWS server - I understand that I should be adding something along the lines of
<CORSConfiguration>
    <CORSRule>
    <AllowedOrigin>http://www.example1.com</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
   <AllowedHeader>*</AllowedHeader>
 </CORSRule>
 <CORSRule>
     <AllowedOrigin>http://www.example2.com</AllowedOrigin>
     <AllowedMethod>PUT</AllowedMethod>
     <AllowedMethod>POST</AllowedMethod>
     <AllowedMethod>DELETE</AllowedMethod>
     <AllowedHeader>*</AllowedHeader>
 </CORSRule>
 <CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
 </CORSRule>
</CORSConfiguration>
from AWS docs: AWS EC2 CORS
However I'm unsure of where I actually need to add this too. My AWS server knowledge it limited.
It's a Neo4j db and the call is:
getRequest = function () {
    $.ajax({
        url: 'http://exampleEC2:port/',
        type: 'POST',
        dataType: 'JSON',
        contentType: 'application/json;charset=UTF-8',
        password: 'xxxxxx',
        username: 'xxxx',
        data: dataObject,
        success: function (data) {
            console.log("success");
        },
        error: function(error) {
            console.log(error);
        }
    });
};
 
     
     
     
     
    