So I tried out my approach and it works. You have to do two things: 1) add the specific CORS headers to each response 2) handle OPTIONS requests, since these requests are automatically send from most of the browsers as a "preflight" CORS request and couchbase light has no handler for the OPTIONS method.
The class to be modified: https://github.com/couchbase/couchbase-lite-java-listener/blob/master/src/main/java/com/couchbase/lite/listener/LiteServlet.java The code: @Override public void service(HttpServletRequest request, final HttpServletResponse response)throws ServletException, IOException { // Handle OPTIONS request in order to respond to CORS response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE"); response.setHeader("Access-Control-Allow-Headers", "content-type, accept"); if("OPTIONS".equals(request.getMethod())){ Log.v(Log.TAG_LISTENER, "Handle OPTIONS request in order to respond to CORS"); response.setStatus(200); return; } ... } I also attached the modified library for the Phonegap plugin for Android (couchbase-lite-java-listener-1.0.0-72.jar). Hope that helps, cheers, Stefan -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/85302a9e-ae34-4c38-8c68-a30f5b573303%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
couchbase-lite-java-listener-1.0.0-72.jar
Description: application/java-archive
