I try to access my REST API that I built using Finatra via AJAX calls. Unfortunately, I get the following error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have read about enabling CORS, but I could not find out how to do this in Finatra 2.1.6. I have seen that there is a policy that could be enabled and is very permissive, but I somehow do not manage to get it running. In my code I wrote:
override def configureHttp(router: HttpRouter) {
router
.filter(new HttpFilter(Cors.UnsafePermissivePolicy))
.add(controller)
}
How can I set the headers properly to allow CORS in Finatra?