You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect I can query the database after login without getting 401
Current Behavior
I am getting 401 after successful login
Code
let PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-authentication'))
let localDb = PouchDB(dbConfig.dbName);
let remoteDb = PouchDB(`http://${dbConfig.host}:5984/${dbConfig.dbName}`, { skip_setup: true })
remoteDb.login(dbConfig.username, dbConfig.password).then( result => {
console.log(result) // <--- { ok: true, name: 'admin', roles: [ '_admin' ] }
remoteDb.get(id).then( r => console.log(r)).catch( e => console.log(e));
// Prints
// {
// error: 'unauthorized',
// reason: 'You are not authorized to access this db.',
// status: 401,
// name: 'unauthorized',
// message: 'You are not authorized to access this db.',
// docId: 'some_id'
// }
}).catch( e => logger.error(`${TAG}: ${e}`))
Your Environment
Version of PouchDB Authentication: 1.1.3
Version of PouchDB: 7.2.1
Platform name and version: Node.js 12.16.3
PS: I am connecting to the same database from a different project using JavaScript and PouchDB 7.2.1 and auth 1.1.3 (so exactly the same) and it works jut fine
The text was updated successfully, but these errors were encountered:
After login, the subsequent request does not carry the token of permission verification,i don't understand why there are such low-level mistakes here, but the problem can be solved in the following ways:
let remoteDb = PouchDB( http://${dbConfig.host}:5984/${dbConfig.dbName},
{
skip_setup: true,
fetch:function(url,opts){
opts.headers.set('Authorization','Basic ' + btoa(dbConfig.username+":"+dbConfig.password'););
}
})
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
I expect I can query the database after login without getting 401
Current Behavior
I am getting 401 after successful login
Code
Your Environment
PS: I am connecting to the same database from a different project using JavaScript and PouchDB 7.2.1 and auth 1.1.3 (so exactly the same) and it works jut fine
The text was updated successfully, but these errors were encountered: