Skip to content

getUser throw 404 if prefix defined #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nueko opened this issue Jun 13, 2017 · 1 comment
Closed

getUser throw 404 if prefix defined #158

nueko opened this issue Jun 13, 2017 · 1 comment

Comments

@nueko
Copy link

nueko commented Jun 13, 2017

using webpack, node 6.x npm 5.x

const Couch = PouchDB.defaults({
  prefix: "http://127.0.0.1:5984",
  skip_setup: true
});

const db = new Couch({
  name: "speda"
});
db.getUser('foo', function (err, response) {
  if (err) {
    if (err.name === 'not_found') {
      // typo, or you don't have the privileges to see this user
    } else {
      // some other error
    }
  } else {
    // response is the user object
  }
});

capture2
capture1
G)

@nueko
Copy link
Author

nueko commented Jun 13, 2017

After some digs, I reproduced the issue when i use prefix options.
also options provided by defaults static method not merged

nueko pushed a commit to nueko/pouchdb-authentication that referenced this issue Jun 13, 2017
@nueko nueko changed the title getUser throw 404 in console but ok if open on new tab getUser throw 404 if prefix defined Jun 13, 2017
tlvince added a commit to tlvince/pouchdb-authentication that referenced this issue Nov 15, 2017
If [PouchDB.defaults][1] is used, its options are attached to `__.opts`.

In the case of `PouchDB.defaults({prefix: ''})`:

> `prefix` appends a prefix to the database name and can be helpful for
> URL-based or file-based LevelDOWN path names.

For example: `{prefix: 'https://example.com/', name: 'test'}` would
produce a DB "name" of `https://example.com/test`.

Before, prefix was not respected.

Closes pouchdb-community#158.
Connects pouchdb-community#160.

[1]: https://pouchdb.com/api.html#defaults
ptitjes added a commit to ptitjes/pouchdb-authentication that referenced this issue Nov 17, 2017
The authentication tests were mixed in with urls tests. Also, the
url tests were enhanced to take in account use of urlParse and
handling of db prefixes. (cf. pouchdb-community#150 and pouchdb-community#158)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants