title: Access-Control-Allow-Origin header not found after CORS filter added
body: <p>I implemented a login form with AngularJS for user authentication. Below is my service for login with post request:</p>
  
  <pre><code>app.factory("loginFactory", function ($http) {
      return{
          login: function(username, password) {
              var data = "username="+username+"&amp;password="+password+"&amp;submit=Login";
              return $http({
                  method: 'POST',
                  url: 'http://localhost:8080/login',
                  data: data,
                  headers: {
                      'Content-Type': 'application/x-www-form-urlencoded',
                  }
              });  
          }
      }   
  });
  </code></pre>
  
  <p>Got the following error when I run it.</p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost:8080/login.No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8081' is therefore not allowed access.
  </code></pre>
  
  <p>I did some research and found out the header has to be added on server side. According this <a href="https://stackoverflow.com/questions/32319396/cors-with-spring-boot-and-angularjs-not-working">post</a>, I added the following to my Rest Service </p>
  
  <pre><code>@Component
  public class SimpleCORSFilter implements Filter {
  
      @Override
      public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
  
          HttpServletRequest request = (HttpServletRequest) req;
          HttpServletResponse response = (HttpServletResponse) res;
  
          response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
          response.setHeader("Access-Control-Allow-Credentials", "true");
          response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
          response.setHeader("Access-Control-Max-Age", "3600");
          response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me");
  
          chain.doFilter(req, res);
      }
  
      @Override
      public void init(FilterConfig filterConfig) {
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p>However, I still got the same error. </p>