在我的 CouchDB 设置中,我有以下配置
- 配置中的 CORS 已启用(它在我锁定数据库之前有效)
- 存在名称为
admin
密码为admin
的基本管理员
localsite 是 http://localhost/mysite
而 couchdb 位于 http://localhost:5984/
我避免使用任何服务器端脚本,只提供静态文件,其余部分在客户端处理,所以如果可能的话,不要根据服务器端PHP
或 node.js
。
尝试使用 $.couch.login
登录,它返回
{"ok":true,"name":null,"roles":["_admin","admin"]}
我尝试请求 $.couch.session
而不是填充的 json 它只是返回
{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":[ “oauth”,“cookie”,“默认”]}}
当我尝试使用 REST 工具时,结果是
{"ok":true,"userCtx":{"name":"admin","roles":["_admin","admin"]},"info":{"authentication_db": "_users","authentication_handlers":["oauth","cookie","default"],"authenticated":"cookie"}}
当使用 REST 工具时,它允许我继续,添加文档、删除等等。
我到底错过了什么?
最佳答案
下面的代码允许在 header 中使用 cookie。
$.ajaxSetup({
跨域:真
,xhrFields:{ withCredentials:true}});
关于javascript - 无法使用 $.couch.login 授权 couchdb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19867942/