Couchdb sync access with userid and password

被刻印的时光 ゝ 提交于 2019-11-28 05:40:29

问题


I have a couchdb running on a virtual linux machine. This db has cors enabled and setup. I have added an admin user and password to the db. I also have require_valid_user set to true. I am trying to sync a pouchdb in a web page with the couchdb online with the code below. If I just pass the address for the db (1 below), I get a dialog box asking for a user and password. The sync works in this example. If I try to pass the user name and password in the URL (as in 2 below), I get a sync error and the message "getCheckpoint rejected with ". Any suggestions on what I am doing wrong or another approach I should taking with this would be greatly appreciated.

thanks

P.S. I am able to browse to the URL with the user and password.

var remoteCouch = "http://192.168.1.7:5984/mydb";  //1
//var remoteCouch = "http://userid:password@192.168.1.7:5984/mydb"; //2
sync();

function sync() {
  var opts = {live: true};
  db.sync(remoteCouch,opts,syncError);
}

回答1:


I had the same problem with the exact same error message trying to sync to a couchDB on cloudant.com. For me, the solution was to use https:// instead of http:// in the URL of the remote server. The format of the URL should be:

https://<api_key>:<key_passwd>@<username>.cloudant.com/<db_name>

So although I do not have a locally installed DB to test this, I suspect your error stems from the fact that couch redirects the request to a secure connection when you provide your credentials (scenario 1). While in scenario 2 no redirect occurs.



来源:https://stackoverflow.com/questions/38780973/couchdb-sync-access-with-userid-and-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!