node.js - Unauthorised admin on Cloudant Local using nodejs-cloudant (nano) -


i've been trying cloudant local going couple of hours. i've installed via docker described here

i can access dashboard on localhost:8080 default creds. , can curl db when supply same creds e.g. curl -x put $host/database -u admin:pass

the problem is, when connect nodejs-cloudant module 401 - unauthorised errors, specifically:

{ error: 'unauthorized', reason: 'one of _all_dbs, _admin, server_admin required request', statuscode: 401 }

it seems issue there no user being returned when cloudant local connects. when connect cloud based cloudant instance, reply.userctx populated, when connecting locally is: userctx: { name: null, roles: [] } }

the actual login seems working though i've tested incorrect creds.

this setting credentials:

    const credentials = {        account: (stage === 'local') ? 'admin' : db.credentials.username,        password: (stage === 'local') ? 'pass' : db.credentials.password,        plugin: 'promises',      }      if (stage === 'local') {        credentials.url = 'http://localhost:8080'      }      this.cloudant = cloudant(credentials)

any appreciated, thanks!

if supply url this:

var url="http://admin:pass@localhost:8080"; this.cloudant = cloudant({ url: url, plugin: "promises"}); 

then works fine.

the problem when account = 'admin', library assumes hostname of admin.cloudant.com. if supply full url, unambiguous , works perfectly.

hope helps.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -