title: CORS Angular and SpringBoot - request blocked
body: <p>I have a problem that I don't seem to figure out.
  I want to send a http request from my </p>
  
  <p>Angular client:</p>
  
  <pre><code>const url = 'http://localhost:8080/api';
  console.log(this.http.get(url).subscribe(data =&gt; this.greeting = data));
  </code></pre>
  
  <p>to SpringBoot backend where I use CORS annotation:</p>
  
  <pre><code>@CrossOrigin(origins = "http://localhost:4200/", maxAge = 3600)
      @RequestMapping("/api/")
      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>but I'm getting an error that it's blocked and redirects me to login all the time.</p>
  
  <pre><code>Failed to load http://localhost:8080/api: Redirect from 'http://localhost:8080/api' to 'http://localhost:8080/login' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. 
  </code></pre>
  
  <p>Is there a way to change that?</p>
  
  <p>I appreciate any hint or help regarding this. I would like to understand why this problem is happening.</p>