Couchbase Lite REST API preflight requests

Is it possible to enable the Couchbase Lite REST API to support preflight OPTIONS requests?

I am developing an Ionic / Cordova hybrid app. In my development environment, I use ionic’s “emulate” command, which kicks off the iOS simulator with source files hosted in a local web server to enable live reloading. This has the side effect of creating a CORS situation, causing UIWebView to send OPTIONS requests to the local REST API host (http://lite.couchbase.) for certain types of requests. The API fails on these requests and does not complete the intended database operation.

I’m able to get around this for simple requests (https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests) but can’t avoid it for DELETEs, for instance.

If Couchbase Lite could handle these OPTIONS requests it would make my development workflow much simpler.

Which version of Couchbase Lite are you running?

If you take a look at the 4th point in the description of this PR on the Android SDK https://github.com/couchbase/couchbase-lite-java-core/pull/1388, it seems to cover what you described. Not sure if it’s also available iOS but you could check on Android with 1.3.1 first to see if it resolves your issue.

James

There’s no OPTIONS support in the iOS version. You can file an issue on Github requesting it. I don’t know if we’d consider it a priority, though; but if you were to implement it and create a pull request, it’s likely we’d merge it.

Thank you for your response. I will look into what is involved in making the change.

Do you happen to have a fix for this issue? If not, I’ll also take a look at integrating CORS support.