title: CORS Allow all on same Server different Ports in JAVA
body: <p>I have my Project running on <strong>www.example.com:8888</strong>, and my project needs an <strong>API</strong> which is running on the same Server in a different PORT (<strong>www.example.com:8081</strong>). Now I'm facing a <strong>CORS</strong> issue when communicating with the <strong>API</strong></p>
  
  <p>Below is my JAVA code extract of API:</p>
  
  <pre><code>@GET
  @Path("/getFiles")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response gettingJsonFiles(@QueryParam("data") String data) throws IOException {
  List&lt;org.json.JSONObject&gt; jsonList=JsonService.gettingJsonFiles(data);
  return Response.ok(jsonList.toString()).header("Access-Control-Allow-Origin", "*")
  .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
  .header("Access-Control-Allow-Headers", "X-Requested-With")
  .allow("OPTIONS").build();
  
  }
  </code></pre>