2

I am trying to setup CORS in java playframework 2.4.x withouth success. My front-end app is using AngularJS 1.3.x.

I implemented the Filters class as per documentation but my preflights OPTIONS requests from AngularJS fail without apparent reason.

This is my application.conf values regarding the filter:

NOTE: I edited the domain names (I am not the owner of example.com) ;)

...
play.filters.cors {
    allowedOrigins = ["http://example.com", "http://beta.example.com", "http://example.com/beta"]
    allowedHttpMethods = ["GET", "POST", "PUT", "OPTIONS", "DELETE"]
    allowedHttpHeaders = ["Accept", "Content-type"]
    preflightMaxAge = 3 days
}
...

My play application is hosted in a separate server from the front-end: I essentially have a sub-directory on my main hosting containing the Angular app and a subdomain pointing to the play server.

Any ideas/suggestions on where I should investigate?

2
  • I have to ask it: did you put meaningful origins in the allowedOrigins array and not just example.com (assuming you are not the owner of example.com) :) Commented Jul 8, 2015 at 12:08
  • @Anton Sorry I should have edited the question to specify that of course I've put my own domains. :) Edited now. Commented Jul 8, 2015 at 12:14

1 Answer 1

2

After 3 days struggling on this I finally understood what was the problem. Apparently a module of Cisco AnyConnect VPN was blocking all the OPTIONS preflight requests.

Nothing related to Play or AngularJS.

Here's a the link from where I found the solution: http://www.bennadel.com/blog/2559-cisco-anyconnect-vpn-client-may-block-cors-ajax-options-requests.htm

It was enough just to uninstall the client and boom! Everything was working again!

Posting as reference for others that might have the same problem.

Best, E.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.