Spring boot, security Cors configuration problem: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status

AFAIK in order for CORS to be properly configured you also need to specify the allowed origins, headers and other stuff if applicable for your use case. So your CORS mapping would become:

@Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") //or whichever methods you want to allow
                .allowedOrigins("*") //or www.example.com if you want to be more specific
                .allowedHeaders("Content_Type", "Authorization"); //i also put Authorization since i saw you probably want to do so
    }

Check this picture, maybe it makes you understand better how it works.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top