I\'m using spring boot to make a simple rest service. To consume it in Angular 2, I\'ve got CORS problem when retrieving token on oauth/token endpoint.
The error mes
The browser checks CORS settings via a request with OPTIONS header. And if you've configured authorization, OPTIONS request will be blocked as unauthorized.
You simply can add cors support in WebConfigurerAdapter.
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// ...
http.cors();
}
}
Check this link for more info: https://www.baeldung.com/spring-security-cors-preflight