Performance: CORS configuration in Security
MEDIUM IMPACT
This affects how quickly the browser can safely load resources from different origins without blocking or delays.
http.cors().configurationSource(request -> {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(List.of("https://example.com"));
config.setAllowedMethods(List.of("GET", "POST"));
config.setAllowedHeaders(List.of("Authorization", "Content-Type"));
config.setAllowCredentials(true);
return config;
});http.cors().and().csrf().disable(); // No specific CORS config, defaults apply| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Default or no CORS config | N/A | N/A | Blocks rendering until preflight completes | [X] Bad |
| Explicit CORS config with limited origins and methods | N/A | N/A | Allows faster resource loading, no blocking | [OK] Good |