2017-06-06 51 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

感謝它現在的工作.. –