title: Spring Boot : CORS Issue
body: <p>I am using Spring Boot version 2.0.2Release.
  Below is my security configuration</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(
          prePostEnabled = true,
          securedEnabled = true,
          jsr250Enabled = true)
  @ComponentScan("com.mk")
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private AuthenticationProvider myAuthenticationProvider;
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.csrf().disable();
          http.cors().configurationSource(corsConfigurationSource())
                  .and()
                  .csrf().disable()
                  .anonymous().and()
                  .authorizeRequests()
                  .antMatchers(HttpMethod.GET,"/index.html").permitAll()
                  .antMatchers(HttpMethod.POST,"/login").permitAll()
                  .antMatchers(HttpMethod.GET,"*").authenticated()
                  .and().httpBasic();
      }
      @Bean
      CorsConfigurationSource corsConfigurationSource() {
          CorsConfiguration configuration = new CorsConfiguration();
          configuration.setAllowedOrigins(Arrays.asList("*"));
          configuration.setAllowedMethods(Arrays.asList("GET","POST"));
          configuration.setAllowCredentials(true);
          UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
          source.registerCorsConfiguration("/**", configuration);
          return source;
      }
  </code></pre>
  
  <p>I am unable to invoke any API (including login which is permitAll) because of CORS issue.</p>
  
  <p>On Browser I am getting (It works with Postman, since CORS check is not made there)</p>
  
  <blockquote>
    <p>Failed to load <a href="http://localhost:8080/myurl" rel="noreferrer">http://localhost:8080/myurl</a>: Response to preflight
    request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:4200" rel="noreferrer">http://localhost:4200</a>' is therefore not allowed
    access. The response had HTTP status code 403.</p>
  </blockquote>