Cannot connect to DB (lite.couchbase.) on iOS 10

Hello,

I can no longer make a connection to the internal URL http://lite.couchbase./ on iOS 10. It triggers a “Preflight, OPTIONS” error. If I recall correctly, the domain shouldn’t be under CORS as it is internally used to redirect the calls. This happens solely on iOS 10, and works fine on previous versions of iOS.

The setup exists of a UiWebview, using the internal domain to handle data storage (basic CRUD operations). I updated the Couchbase Lite .framework files to the latest 1.3.1 version, but no luck so far.

Does anyone encounter the same problems?

Best regards,

Mat.

Sounds like you’re writing your own app in Obj-C or Swift, instead of using an existing shell like PhoneGap?

Make sure you’re getting the root URL from the CBLManager.internalURL property instead of hardcoding http://lite.couchbase./. But I don’t think the URL has changed.

This sounds like some kind of policy change in WebKit that you’ll have to work around, probably by changing the properties (HTML or response headers) of the initial page you load into the WebView that contains the JS that tries to access CBL. Unfortunately I know very little about CORS so I’m not the right person to help out. But we have other people here who know a lot more about it. There might also be some answers in the source code of our PhoneGap plugin.

@pasin, do you know if there were changes that had to be made to the plugin due to WebKit changes like this?

Hey, thanks for the answer.

For my case, CBLManager.internalURL is always http://lite.couchbase./'. I’m no Objective C developer, but from what I understand by reading the source code, the domain is simply an alias that redirects the calls internally.

A PhoneGap example seems to work, but that’s because the files are loaded from a local source. Thus they do not bump upon CORS. I load a site from an external http address, which uses the cache manifest to be available offline. That site performs POST and GET calls on the lite.couchbase. domain in order to store data locally.

Indeed, probably a policy change in WebKit as it seems to work on older iOS versions.

For Android, I recompiled the sourcecode to allow OPTIONS to return 200. Maybe that’s something I should do for iOS also?

We are facing also same issue . same CORS rejected is happening in iOS10 but in iOS9 it works fine.
Any update on this?

Thanks.

1 Like

Has anyone filed an issue in Github on this? (This forum is not an issue tracker.)

@jens, we don’t have any code changes in the plugin.

I believe CBL iOS listener should already return 200 for OPTIONS.

On Android? I had to manually add the correct response code.

if ("OPTIONS".equals(request.getMethod())){
    response.setStatus(200);
    return true;
}

For the iOS library, I cannot find a proper way to add it (yet).

@matvp91 Doesn’t iOS already return 200?

or a different handler method is called?