I have a java play framework 2.4.x web app providing a JSON/HTTP API. When I run my front-end HTML/JS file:///Users/nize/tmp/index.html
calling the API on http://localhost:9000
chrome shows
XMLHttpRequest cannot load http://localhost:9000.
No 'Access-Control-Allow-Origin' header is present
on the requested resource. Origin 'null' is therefore
not allowed access. The response had HTTP status code 403.
I have configured the web app as per the instructions given in Play Framework 2.4.x CORS Documentation:
- Update to
build.sbt
- Added the class
Filters.java
to the root of the project (also tried/app
) - Added the following stanza to the
application.conf
:play.filters.cors { allowedOrigins = ["*","http://localhost"] #allowedHttpMethods = ["GET", "POST"] #allowedHttpHeaders = ["Accept"] #preflightMaxAge = 3 days }
What am I missing?
Edit: The symptoms look identical or similar to Other very similar stackoverflow post. That problem was solved by reconfiguring Cisco AnyConnect VPN which was installed on the computer. I, however, don't have that software installed.
See Question&Answers more detail:os