Reputation: 267077
I have a play framework based backend, which needs to be available to a front-end that will be hosted on a different domain.
E.g the backend could be at backend.example.com and front end could be at myapp.com which will then make javascript requests to backend.example.com
I think this requires sending an access-origin header via play.
Any ideas how / where to configure this, so it is sent for all requests globally?
Upvotes: 1
Views: 58
Reputation: 636
You'll need to use the application.conf file to turn on CORS:
play.filters.enabled += "play.filters.cors.CORSFilter"
Then you can configure the details like this (also on application.conf):
#CORS Properties
cors.enabled=true
cors.allowed_headers=["Accept", "Origin", "Content-type", "Authorization", "X-Auth-Token", "X-HTTP-Method-Override", "X-Json", "X-Prototype-Version", "X-Requested-With", "x-auth-token", "x-auth-id"]
cors.allowed_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"]
cors.allowed_credentials=true
cors.allowed_origin="*"
here is the documentation for more details: https://www.playframework.com/documentation/2.6.x/CorsFilter
Upvotes: 3