2014-04-07 59 views
3

如何將自定義標頭添加到pouchdb中的HTTP同步請求中?以下不起作用。我正在使用需要額外頭文件的中間件代理。我需要添加以下2個頭(授權和APPID)。pouchdb,如何將自定義標頭添加到HTTP同步請求?

var opts = {live: true, complete: syncError, withCredentials:true, headers: {Authorization : 'Basic ' + Base64.encode("user:pass"), 'APPID': 1001}}; 

db.replicate.to(remoteCouch, opts); 

回答

3

the official documentation,您可以通過使用ajax選項添加自定義頁眉(及以上)。例如:

var db = new PouchDB('http://example.com/dbname', { 
    ajax: { 
    cache: false, 
    timeout: 10000, 
    headers: { 
     'X-Some-Special-Header': 'foo' 
    }, 
    username: 'mysecretusername', 
    password: 'mysecretpassword' 
    } 
}); 
相關問題