title: CORS issue in vertx Application not working
body: <p>My Vertx Server resides in server A and client resides in server B. When i tried to access vertx server, CORS error pops in. I added some server side code to handle CORS issue but it's not working. Do we need to add some header in client side. what am i missing here? Can anyone help</p>
  
  <p>Vertx Server Side: </p>
  
  <pre><code>Router router = Router.router(vertx);
  router.route().handler(BodyHandler.create());
  router.route().handler(io.vertx.rxjava.ext.web.handler.CorsHandler.create("*")
  .allowedMethod(io.vertx.core.http.HttpMethod.GET)
  .allowedMethod(io.vertx.core.http.HttpMethod.POST)
  .allowedMethod(io.vertx.core.http.HttpMethod.OPTIONS)
  .allowedHeader("Access-Control-Request-Method")
  .allowedHeader("Access-Control-Allow-Credentials")
  .allowedHeader("Access-Control-Allow-Origin")
  .allowedHeader("Access-Control-Allow-Headers")
  .allowedHeader("Content-Type"));
  </code></pre>
  
  <p>Client implementation:</p>
  
  <pre><code>    function(url, user) {
      eventBus = new EventBus(url);
      eventBus.onopen = function() {
              //Do Something
      }
   }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I removed the withCredential attribute in header.Now my code looks like </p>
  
  <pre><code>if (ar.succeeded()) {
  routingContext.response().setStatusCode(200).setStatusMessage("OK")
  .putHeader("content-type", "application/json")
  .putHeader("Access-Control-Allow-Origin", "*")
  .putHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS")
  .end(
  Json.encodePrettily(ar.result().body())
  //(String) ar.result().body()
  );
  routingContext.response().close(); 
  </code></pre>
  
  <p>but still following error pops up. Can you help?</p>
  
  <pre><code>XMLHttpRequest cannot load https://192.168.1.20:7070/Notify/571/rn4nh0r4/xhr_send?t=1471592391921. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'https://login.com' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
  </code></pre>
  
  <p><strong>Update2:</strong>
  After adding my client address in </p>
  
  <pre><code>.putHeader("Access-Control-Allow-Origin", "*")
  </code></pre>
  
  <p>I got following log:</p>
  
  <pre><code>XMLHttpRequest cannot LOAD https://192.168.1.20:7070/Notify/773/k3zq1z2z/xhr_send?t=1471601521206. Credentials flag IS 'true', but the 'Access-Control-Allow-Credentials' header IS ''. It must be 'true' TO allow credentials. Origin 'https://login.com' IS therefore NOT allowed access.
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code> if (ar.succeeded()) {
  routingContext.response().setStatusCode(200).setStatusMessage("OK")
  .putHeader("content-type", "application/json")
  .putHeader("Access-Control-Allow-Origin", "https://login.com")
  .putHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS")
  .putHeader("Access-Control-Allow-Credentials", "true")
  .end(
  Json.encodePrettily(ar.result().body())
  //(String) ar.result().body()
  );
  routingContext.response().close();
  </code></pre>