这发生在我的 Windows 10 机器、CouchDb 3.1.0 和 Postman 7.29.1 上。
在 DB 课程中,我无法像我的老师那样做并访问:
http://127.0.0.1:5984/_all_dbs
返回 401 错误:
{
"error": "unauthorized",
"reason": "You are not authorized to access this db."
}
我做了一些搜索,但什么也没找到。
注意: 该解决方案适用于本地且不安全的环境,并且无论如何都可以解决任何其他问题。
在 CouchDB/etc 中,打开 default.ini,然后更改以下行:
; When true, system databases _users and _replicator are created immediately
; on startup if not present.
single_node = true
; prevent non-admins from accessing /_all_dbs
admin_only_all_dbs = false
然后重新启动 Apache CouchDB 服务(或重新启动计算机)。瞧!
Obs:另一件可能发生的事情是新数据库上的 401。转到数据库权限并从成员 - 角色中删除 _Admin。