title: Angular HttpClient doesn't send POST, it sends OPTIONS
body: <p>Im' newbie using Angular HttpClient (and writting english too)</p>
  
  <p>I have a problem, I'm trying sending HTTP request with POST method in order to negociate OAuth token obtenction but angular sends OPTIONS request:</p>
  
  <p><em>Service:</em></p>
  
  <pre><code>login(username: string, password: string) {
  const body = `username=${encodeURIComponent(username)}&amp;password=${encodeURIComponent(password)}&amp;grant_type=password`;
  
  const httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': 'Basic ' + btoa(TOKEN_AUTH_USERNAME + ':' + TOKEN_AUTH_PASSWORD)
    })
  };  
  
  
  return this.http.post&lt;string&gt;(AuthenticationService.AUTH_TOKEN, body, httpOptions);
  </code></pre>
  
  <p><em>Result:</em></p>
  
  <p><a href="https://i.stack.imgur.com/i9fyn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/i9fyn.png" alt="enter image description here"></a></p>
  
  <p>For my backend, I'm using Spring Security and i added a filter to allow CORS:</p>
  
  <pre><code>@Bean
  public FilterRegistrationBean corsFilter() {
      UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
      CorsConfiguration config = new CorsConfiguration();
      config.setAllowCredentials(true);
      config.addAllowedOrigin("*");
      config.addAllowedHeader("*");
      config.addAllowedMethod("*");
      source.registerCorsConfiguration("/**", config);
      FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
      bean.setOrder(0);
      return bean;
  }
  </code></pre>