PouchDB 基本身份验证不适用于同步网关

PouchDB basic auth does not work with sync gateway

当我尝试使用同步网关从 PouchDB 同步到 couchbase 服务器时,出现以下错误:

XMLHttpRequest cannot load http://localhost:4984/test/. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

我尝试设置 header 即使这样我也无法摆脱这个错误。 这是我的同步网关配置文件

sync-gateway-config.json::

    {
        "log":["*"],
        "databases": {
            "buildercycle": {
                "server":"http://localhost:8091",
                "bucket": "default",
                "users": {
                    "GUEST": {
                        "disabled": false,
                        "admin_channels": ["*"]
                    }
                },
                "sync":`function(doc, oldDoc) {
                      if (doc.type == "sports"){
                        channel(doc.type);
                        access(doc.owner,doc.type);

                      } else  {
                        channel(doc.type);
                       access(doc.owner,doc.type);
                      } 
                }`

            }
        },
        "CORS": {
            "Origin": ["http://localhost:8000","http://localhost:8083", "http://localhost:4985"],
            "LoginOrigin": ["http://localhost:8000","http://localhost:8083","http://localhost:4985"],
            "Headers": ["Content-Type"],
            "MaxAge": 17280000
        }
    }

    I am trying to sync my PouchDB in following way:
    remoteCouch="http://"+user+":"+pass+"@localhost:4984/buildercycle";
                            console.log(remoteCouch);
      var opts = {live: true,withCredentials: true};
      db.sync(remoteCouch,opts,'error');


    i am passing user(user1) and password(password) which is defined in following sync_gateway admin URL

http://localhost:4985/_admin/db/test/users

我无法查明错误,请帮助

在 headers

中添加授权

"Headers": ["Content-Type","authorization"],

我认为你的情况下 cors header 设置不正确。