2017-06-06 27 views
1

工作摆脱这个错误。 这里是我的同步网关配置文件PouchDB基本身份验证不同步网关

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

我无法针点错误,请帮助

回答

1

添加授权在头

“头”:“内容 - 类型“,”授权“],

我认为在你的情况下,Cors header没有正确设置。

+0

感谢它现在的工作.. –