I am using oauth2 in springboot for the server side and React application on the Client. I am sending the token request for the grant_type client_credentials
to /oauth/token
from react application and get the Above error.
I have used @CrossOrigin
and also used http.cors() for the global security config but still keep seeing the Preflight cors block error in browser console.
Error:
Access to XMLHttpRequest at 'http://localhost:8000/oauth/token' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. xhr.js:177 POST http://localhost:8000/oauth/token net::ERR_FAILED
https://www.youtube.com/watch?v=7Yqb275FKmY helped me up. The issue was the @Order(Ordered.HIGHEST_PRECEDENCE)
on my SimpleCORSFilter
class that implements filter class.