vert.x - sockJS server with access-allow-origin issue.

303 views
Skip to first unread message

Udaya Karthick

unread,
Mar 28, 2016, 2:37:09 AM3/28/16
to vert.x
Hi,


I'm trying to implement proxy for vert.x sockJS server with NGINX.  when i try to  access the eventbus URL from client i get "access-allow-origin" issue. Is there a way to implement CORS to sockJSHandler? 

is this the right way to implement CORS for SockJSHandler(Check below snippet)?


                               router = Router.router(vertx);
                 router.route().handler(CorsHandler.create("*")
.allowedMethod(HttpMethod.GET)
.allowedMethod(HttpMethod.POST)
.allowedMethod(HttpMethod.OPTIONS)
.allowedHeader("X-PINGARUNER")
.allowedHeader("Content-Type"));

SockJSHandler sJSHandler= SockJSHandler.create(vertx).bridge(opts); 
router.route("/message/broadcast/*").handler(sJSHandler);
vertx.createHttpServer().requestHandler(router::accept).listen(port);

Anil

unread,
Apr 12, 2016, 2:01:36 AM4/12/16
to vert.x
It looks good. i was using sockjs handler and i did not see any issue. any reproducer would be good. thanks.
Reply all
Reply to author
Forward
0 new messages