Doug
Doug

Reputation: 15513

Pouchdb / CouchDB all_docs error

I'm setting up a pouchdb / couchdb live sync. I'm using pouchdb-authentication to login.

When on my local dev server, everything works fine.

  let pdbConfig = { skipSetup: true}; 
  let remoteDb : any = new PouchDB(config.couch.server, pdbConfig);
  remoteDb.login(config.couch.username, config.couch.password).then(u => {
    db.sync(remoteDb, {
      live: true
    }).on('complete', (info)=> {
      store.dispatch({type: "REMOTE_SYNC_COMPLETE"});
    })

  }).catch(e=>{
    console.error(e)
  })

On production, I receive this error:

{"error":"case_clause","reason":"{forbidden,<<\"You are not a db or server admin.\">>}"}

Request URL: https://myproductionserver:6984/userdb-82911660-c14b-472c-adb4-6f2ed280cae9/_all_docs?conflicts=true&include_docs=true

I've noticed that this only happens when a new sync occurs (otherwise it does not appear all_docs is called) all_docs doesn't appear to be called at all on my local dev server, regardless of state.

Other calls (to _session, _changes) etc work fine to the production server.

Upvotes: 0

Views: 163

Answers (1)

Doug
Doug

Reputation: 15513

Looks like users need to have admin permissions on a database to use all_docs. My users were only "members. all_docs isn't called in pouchdb unless a database already exists on the couchdb server, but not on the client.

Upvotes: 1

Related Questions