title: No 'Access-Control-Allow-Origin' in angular with Spring-boot / Http call angular 2
body: <blockquote>
    <p>I'm trying to get data to <strong><em>angular application</em></strong> from <strong><em>spring boot server</em></strong>
    via <strong><em>angular http call</em></strong>. Also I have added <strong>security</strong> dependency for spring boot application.</p>
  </blockquote>
  
  <p>When I'm trying with browser this will come.</p>
  
  <p><a href="https://i.stack.imgur.com/4EtCF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4EtCF.png" alt="enter image description here"></a></p>
  
  <p>Once I enter them with the password in console of Intellij it will show the response.</p>
  
  <p><a href="https://i.stack.imgur.com/xmzIC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xmzIC.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>When I'm trying with angular http call it fails and show error on
    topic.</p>
  </blockquote>
  
  <p>My angular component has following code.</p>
  
  <pre><code>constructor(private http: HttpClient) { 
      http.get('http://localhost:8080/resource').subscribe(data =&gt; this.greeting = data);
  }
  </code></pre>
  
  <p>My spring boot application has below code</p>
  
  <pre><code>@RequestMapping("/resource")
  public Map&lt;String,Object&gt; home() {
        Map&lt;String,Object&gt; model = new HashMap&lt;String,Object&gt;();
        model.put("id", UUID.randomUUID().toString());
        model.put("content", "Hello World");
        return model;
  }
  </code></pre>
  
  <p>Also i have read about <strong>Cross-Origin Resource Sharing (CORS)</strong> but it is unclear how to apply those to angular.</p>
  
  <p>My error is:</p>
  
  <p><a href="https://i.stack.imgur.com/Fp47N.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Fp47N.png" alt="enter image description here"></a></p>