Preflight OPTIONS Request
findAllCandidat() {
return this.http.get<any[]>(${BASIC_URL}api/cvs/recrutement, { withCredentials: true });
}
Fixed CorsConfig
Update your CorsConfig class to explicitly allow allowedHeaders and allowedMethods:
@Configuration public class CorsConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:4200")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*");
}
};
}
}