title: AngularJs -- Access to XMLHttpRequest has been blocked by CORS policy
body: <p>error :</p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="http://localhost:8080/api/v1/locations" rel="nofollow noreferrer">http://localhost:8080/api/v1/locations</a>' from origin '<a href="http://localhost:8000" rel="nofollow noreferrer">http://localhost:8000</a>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  </blockquote>
  
  <p>I test the get method in a request.http file of WebStorm and in Postman and that work , but that doesn't work in my Angularjs project .
  (I get from a Spring boot java project).</p>
  
  <pre><code>var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope, $http) {
      $http.get("http://localhost:8080/api/v1/locations")
              .then(function(response) {
                $scope.result = response.data;
                console.log("OK:", response.data);
              }).catch(function(response) {
                console.log("ERROR:", response);
      });
    });
  </code></pre>
  
  <p>my get function return something like this in postman </p>
  
  <pre><code>[
   {
     "datetime": "2019-01-10T19:00:00.000+0000",
  "user": {
    "firstName": "thr",
    "lastName": "an",
    "id": 1
  },
  "speed": 0.0,
  "latitude": 37.421998333333335,
  "longitude": -122.08400000000002,
  "id": 1
  },
  
  {
     "datetime": "2019-01-10T19:01:00.000+0000",
  "user": {
    "firstName": "thr",
    "lastName": "an",
    "id": 1
  },
  "speed": 1.575,
  "latitude": 37.42198333333335,
  "longitude": -122.080000000002,
  "id": 2
  }
  ]
  </code></pre>
  
  <p>the console : <a href="https://i.top4top.io/p_1507d02621.jpg" rel="nofollow noreferrer">https://i.top4top.io/p_1507d02621.jpg</a></p>
  
  <p><a href="https://i.stack.imgur.com/qQrJn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qQrJn.jpg" alt="enter image description here"></a></p>