Search code examples
javareactjsspring-bootannotations

Access to XMLHttpRequest at 'http://localhost:8080/blog/updatePost/2' from origin 'http://localhost:3000' has been blocked by CORS policy:


Even though I used @CrossOrigin annotation this error still appears. Spring boot app is running on 8080 port and react app is running on 3000 port.

image of backend controller

Error:

Error in console

If further information is needed, please let me know.


Solution

  • I assume you are using spring security. @CrossOrigin filter might have a lower precedence over spring security filters. Try to configure CORS using spring security.