Skip to content
Advertisement

Java – Spring Boot: Access-Control- Allow-Origin not working

I tried to implement Access-Control- Allow-Origin in spring boot using few tutorials and this link but not able to implement this.

To implement this, in application.properties file, I added below line

JavaScript

Which probably means that except the URL https://example.com, no other endpoint can call any APIs. But it’s not working I still can see * in response , in below image. Which menas from other domains, my APIs are accessible. So how to prevent this?

enter image description here

Advertisement

Answer

Finally, I resolved this problem by adding the following in my Application class.

JavaScript

So the final Application class will look something similar to this

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement