I\'m trying to set CORS Headers for my play framework app. Specifically I\'m getting this error
cannot load http://127.0.0.1:9000/. No \'Access-Control-Allow
I would not recommend writing/using any code to enable CORS which is basically a framework feature and only needs configuration.
The stuff you copied from the documentation is correct:
cors.conf where you modify the play.filters.cors settings. But you seem to have misconfigured something, e.g. the allowedOrigin = * should be configured as null in the config. (Have a look at the documentation page and the linked reference.conf)# The allowed origins. If null, all origins are allowed.
play.filters.cors.allowedOrigins = null
CORSFilter in your Filters.scalacurl -H "Origin: http://example.com" \
-H "Access-Control-Request-Method: GET" \
-H "Access-Control-Request-Headers: X-Requested-With" \
-X OPTIONS --verbose \
http://localhost:9000/