I've been working on a project using spring + spring security on my backend and have recently run into an issue with cors specifically:
The first two lines you can see successful api call output, following that chrome attempts to send a Http request with an options header to my rest service.
My question is what could potentially be the source of this issue?
My front end in dev uses the angular CLI client, I havent had any issues with CORS until i created a custom filter for spring security hence adding my WebConfigurerAdapter
config. Happy to supply additional code if required. However I don't think its related to that as I've removed the filter and the same issue occurs.
Tested in chrome, firefox and ubuntu browser same issue occurs.
Angular CLI is successfully proxying calls to '/api/[blah]'
Here's my proxy config, i've tried just matching on everything but that makes no difference.
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
WebSecurityAdapter
Config
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/index.html", "/api/registration", "/api/authenticate",
"/api/isAuthenticated", "/api/validateCaptcha", "/console", "/api/loginRecaptchaRequired", "/api/login", "/")
.permitAll()
.anyRequest()
.authenticated()
.and()
.addFilterBefore(
authenticationFilter(),
UsernamePasswordAuthenticationFilter.class)
.logout()
.logoutUrl("/api/logout")
.and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.addFilterAfter(csrfHeaderFilter(), SessionManagementFilter.class);
}