2

I need to enable CORS (Cross Origin Resourcing) on my App, I am using jersey in Webservice. Setting the Access control origin in response header isn't helping.

headers.put("Access-Control-Allow-Origin", "*");
headers.put("Access-Control-Allow-Methods","GET, POST, DELETE, PUT, OPTIONS, HEAD");
headers.put("Access-Control-Allow-Headers", "X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept");
headers.put("Access-Control-Max-Age", "1728000");
headers.put("Access-Control-Allow-Credentials", "true");

Apart from trying to set the header I even tried ContainerResponseFilter which didn't work, setting this on the client side using angular in myApp.config as below,

$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];

also didn't work.

jersey version : 1.19

java: 1.7

Ilya Luzyanin
  • 7,910
  • 4
  • 29
  • 49
zillani
  • 1,070
  • 3
  • 18
  • 26
  • please give your request code to your server – Gujarat Santana Dec 10 '15 at 14:36
  • check this question http://stackoverflow.com/questions/23450494/how-to-enable-cross-domain-requests-on-jax-rs-web-services – Zoran Pandovski Dec 10 '15 at 14:38
  • Thanks, I noticed that CORS settings are working fine from Postman, the response has all the required headers. The problem arises when I tried from the browser (both FF and Chrome). Is there any kind of setting in angular JS that would resolve the issue ? Another important observation is that this error occurs only in the POST request, things are just fine in GET, on both browser and postman. – zillani Dec 11 '15 at 08:51

0 Answers0