I would like to do cross origin communication using Grails in server side. The only documentation that I found is this one
https://grails.org/plugin/cors
but this is for an old version of Grails. The other documentation that I found is for spring:
https://spring.io/guides/gs/rest-service-cors/
so I added the file SimpleCorsFilter.groovy
to init/myproject/
folder, but I don't know how to wire this component into resources.groovy
Simply activate the add-on and perform the request. CORS or Cross-Origin Resource Sharing is blocked in modern browsers by default (in JavaScript APIs). Installing this add-on will allow you to unblock this feature.
So, if you got here using grails 3.2.+ you can use the default way.
Go to your application.yml
and add:
grails:
cors:
enabled: true
It will add Access-Control-Allow-Origin '*'
.
If you want something different, look this page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With