简体   繁体   English

Chrome 本地 IndexedDB (PouchDB) 复制到 CouchDB 问题

[英]Chrome local IndexedDB (PouchDB) replication to CouchDB problem

I made a localDB in chrome with pouchdb(v 6.2.0).我用 pouchdb(v 6.2.0) 在 chrome 中制作了一个 localDB。 It was created in IndexedDB.它是在 IndexedDB 中创建的。

var localdb = new PouchDB('localDB');

And I made a new couchdb(v3.1.0) in Ubuntu 18.04.我在 Ubuntu 18.04 中创建了一个新的 couchdb(v3.1.0)。 And I make a public database with no user in permissions.我创建了一个没有用户权限的公共数据库。 And the couchdb changed settings to enable the Cross-origion resource sharing (CORS).并且 couchdb 更改了设置以启用跨域资源共享 (CORS)。 And it works well with curl operation in local connection.它适用于本地连接中的 curl 操作。

I create new remote db in chrome with pouchdb.我用 pouchdb 在 chrome 中创建了新的远程数据库。 But the remote db's replication failed with 'message: "getCheckpoint rejected with "'.但是远程数据库的复制失败,并显示“消息:“getCheckpoint 被拒绝”。

var remotedb = new PouchDB('http://admin:password@127.0.0.1:5984/remoteDB');

localdb.replicate.to(remotedb).on('complete', function () {
   console.log('Done');
}).on('error', function (err) {
   console.log('Error', err);
});

remotedb.info() failed with 'name: "unknown"' message. remotedb.info() 失败并显示“名称:“未知”消息。

try {
  ret = await remotedb.info();
} catch (err) {
  console.log('error', err);
}

I am guessing that the remoteDB of pouchdb in chrome have problem.我猜测 chrome 中 pouchdb 的 remoteDB 有问题。 However, I am not sure what is the exact cause.但是,我不确定确切的原因是什么。

I found the answer to the above question.我找到了上述问题的答案。 It was a simple novice mistake.这是一个简单的新手错误。 The answer was CORS and HTTPS issues.答案是 CORS 和 HTTPS 问题。 Below is a workaround.下面是一个解决方法。

Chrome's CORS solved it by turning off web security. Chrome 的 CORS 通过关闭网络安全解决了这个问题。

chrome --disable-web-security --user-data-dir

https://medium.com/@baphemot/understanding-cors-18ad6b478e2bhttps://medium.com/@baphemot/understanding-cors-18ad6b478e2b

And HTTPS is a Self Signed Certificates, which was a problem that Chrome rejected. HTTPS 是自签名证书,这是 Chrome 拒绝的问题。

https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=48203146 https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=48203146

Looking for two answers, database replication worked fine.寻找两个答案,数据库复制工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM