intermediateCORS: Cross-Origin Resource Sharing

Why does @CrossOrigin on a controller sometimes still fail with Spring Security enabled?

Spring Security's filter chain processes (and can reject) requests BEFORE they ever reach your Spring MVC controller, where @CrossOrigin is evaluated. If Spring Security itself isn't configured with a matching CorsConfigurationSource via http.cors(...), the security layer may block or mishandle the request/preflight before MVC-level CORS handling ever gets a chance to run.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why is allowedOrigins('*') combined with allowCredentials(true) rejected by browsers?← Back to all Spring Security questions