2014-04-07 2 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' 
    } 
}); 
관련 문제