I see an issue because Spring Security takes full control of CORS once you enable http.cors(withDefaults())
, which means @CrossOrigin
on your controller gets ignored.
Option 1: Remove the global CORS config from Spring Security.
Option 2: Instead of using @CrossOrigin
, configure CORS rules per endpoint.