title: Angular 6 with Spring security webflux blocked by CORS
body: <p>I am trying to write an application that uses Springs WebFlux Security.  On the front-end angular application I am taking the user to a login page and once they are logged in the application should redirect to a different uri.  As of right now I am getting this error:</p>
  
  <pre><code>     Failed to load http://localhost:8080/login: Redirect from 
       'http://localhost:8080/login' to 'http://localhost:8080/pets' 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>Currently I am not sure why I am having a CORS error but here is what I have for the spring webflux security</p>
  
  <pre><code>@EnableWebFluxSecurity
  public class SecurityConfig {
  
  @Autowired
  private ReactiveUserDetailsService reactiveUserDetailsService;
  
  @Bean
  public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
      http
              .authorizeExchange()
              .pathMatchers(HttpMethod.POST, "/login").permitAll()
              .pathMatchers(HttpMethod.POST, "/logout").permitAll()
              .pathMatchers(HttpMethod.POST, "/register").permitAll()
              .anyExchange().authenticated()
              .and()
              .httpBasic().disable()
              .csrf().disable()
              .formLogin()
              .authenticationManager(authenticationManager())
              .requiresAuthenticationMatcher(ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, "/login"))
              .authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/pets"))
              .authenticationFailureHandler(new ServerAuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint()))
              .authenticationEntryPoint(new HttpBasicServerAuthenticationEntryPoint())
              .and()
              .logout()
              .logoutSuccessHandler(((exchange, authentication) -&gt; Mono.fromRunnable(() -&gt; exchange.getExchange().getResponse().setStatusCode(HttpStatus.OK))));
  
      return http.build();
  }
  
  @Bean
  public ReactiveAuthenticationManager authenticationManager() {
      UserDetailsRepositoryReactiveAuthenticationManager authManager =
              new UserDetailsRepositoryReactiveAuthenticationManager(reactiveUserDetailsService);
  
      authManager.setPasswordEncoder(passwordEncoder());
      return authManager;
  }
  
  @Bean
  PasswordEncoder passwordEncoder() {
      return PasswordEncoderFactories.createDelegatingPasswordEncoder();
  }
  }
  </code></pre>
  
  <p>Is there something that I am missing or need to edit?</p>