【问题标题】:PouchDB sync not sending credentials to CouchDBPouchDB 同步不向 CouchDB 发送凭据
【发布时间】:2017-10-16 14:40:30
【问题描述】:

我有一个安全的 CouchDB 实例正在运行。对于复制,我按照“入门”指南中的说明进行操作。但是 PouchDB 似乎没有将我的凭据发送到服务器,所以我从 CouchDB 收到“需要身份验证”错误。

再现

this.db = new PouchDB('nfcs');    
this.remote = 'https://USER:PASSWORD@couchdb.pixelarbeit.de/nfcs';

let options = {
    live: true,
    retry: true,
    continuous: true
};

this.db.sync(this.remote, options)
    .on('error', err => console.log('PouchDB Error NFCs', err))
    .on('active', err => console.log('PouchDB Active', err))
    .on('complete', err => console.log('PouchDB Complete', err));

标头发送到服务器

Request URL:https://couchdb.pixelarbeit.de/nfcs/
Request Method:OPTIONS
Status Code:401 Unauthorized
Remote Address:185.26.156.40:443
Referrer Policy:no-referrer-when-downgrade
Response Headers

Access-Control-Allow-Origin:http://localhost:8100
Access-Control-Expose-Headers:Cache-Control, Content-Type, Server
Cache-Control:must-revalidate
Connection:close
Content-Length:61
Content-Type:text/plain; charset=utf-8
Date:Mon, 16 Oct 2017 06:12:45 GMT
Server:CouchDB/1.6.1 (Erlang OTP/17)
WWW-Authenticate:Basic realm="server"
Request Headers

Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2,es;q=0.2
Access-Control-Request-Headers:authorization
Access-Control-Request-Method:GET
Cache-Control:no-cache
Connection:keep-alive
Host:couchdb.pixelarbeit.de
Origin:http://localhost:8100
Pragma:no-cache
Referer:http://localhost:8100/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

【问题讨论】:

  • 你为什么要手动设置remote,而不是db = new PouchDB("https://USER:PASSWORD@couchdb.pixelarbeit.de/nfcs");的正常方式?
  • 我以前用过这种方式,但由于它没有发送凭据,我认为这可能是问题的一部分。我在“入门”指南中发现它是这样的,所以我尝试了这种方式。

标签: couchdb pouchdb


【解决方案1】:

我刚刚解决了这个问题。似乎 PouchDB 插件破坏了功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多