79452217

Date: 2025-02-19 17:12:42
Score: 1
Natty:
Report link

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("*");
        }
    };
}

}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Configuration
  • Low reputation (1):
Posted by: manish parihar