CouchDB 和 PouchDB 之间数据不同步

Data not syncing between CouchDB and PouchDB

我正在尝试使用双向复制在客户端上使用 PouchDB 并在服务器上使用 CouchDB 构建一个基本应用程序。

在我的客户端上:

db = new PouchDB('mydb');
.
.
.
sync = db.sync('mydb', 'http://localhost:5984/mydb', {
  live: true,
  retry: true
}); // .on() calls left out for brevity, but they are in the code and they are firing

我在指定的 url 有一个 CouchDB 服务器 运行。 curling url 提供了预期的响应。但是,没有 PouchDB 上的数据被“推送”到服务器 CouchDB。预期的事件正在触发,但没有数据被保存到服务器。在“更改”事件中,我得到以下信息:

doc_write_failures: 0
docs: Array[0]
docs_read: 0
docs_written: 0
errors: Array[0]

目前,我正在尝试与 CouchDB 同步的 PouchDB 数据库中有两个文档。向 PouchDB 添加新数据不会触发同步。

有什么想法吗?我难住了...

编辑

当我将 sync() 调用更改为以下内容时:

sync = db.sync('http://localhost:5984/mydb', ...)

我在 js 控制台中收到以下错误:

http://localhost:5984/mydb/?_nonce=1437507025317 net::ERR_FAILED

您是否在 CouchDB 上启用了 CORS? https://github.com/pouchdb/add-cors-to-couchdb

事实证明,问题是我使用的是应用程序缓存 api,而我的清单文件没有在网络部分引用服务器数据库。

类似问题here