javascript - 无法使用 $.couch.login 授权 couchdb

标签 javascript jquery couchdb

在我的 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/

相关文章:

javascript - Prototype.js 错误 - 'undefined' 为空或不是对象

javascript - 如何在 React 中管理同一页面上的多个相同组件及其各自单独的 axios 请求?

javascript - __proto__ 和 JavaScript 中的继承

javascript - JQuery Masonry 是怎么来的,当我在浏览器上单击 "back"时,它会将用户射回顶部?

database-design - nosql (couchdb) 开发人员使用哪些数据建模工具?

configuration - 如何找到CouchDB的local.ini文件,以便自定义其设置?

javascript - 添加使用 jquery 使用鼠标和浏览器进行滚动的类

jquery - 数据表多列排序不起作用

jquery - 使用 jQuery 访问列表项的文本

tomcat - Spring Cloud Zuul 反向代理在 URL 编码时不从 CouchDB 获取数据