Reputation: 113
I have a problem when I try to replicate a database from PouchDB to CouchDB.
Here is the code I use for database replication
var db = new PouchDB('todos');
var remoteCouch = 'http://localhost:5984/db/';
function sync() {
var opts = {live: true};
db.replicate.to(remoteCouch, opts);
};
Upvotes: 3
Views: 639
Reputation: 11620
Edit: there is now an add-cors-to-couchdb script that makes this dead-simple:
npm install -g add-cors-to-couchdb && add-cors-to-couchdb
As documented in the PouchDB getting started guide, to enable CORS you need to do:
$ export HOST=http://username:[email protected]
$ curl -X PUT $HOST/_config/httpd/enable_cors -d '"true"'
$ curl -X PUT $HOST/_config/cors/origins -d '"*"'
$ curl -X PUT $HOST/_config/cors/credentials -d '"true"'
$ curl -X PUT $HOST/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"'
$ curl -X PUT $HOST/_config/cors/headers -d \
'"accept, authorization, content-type, origin"'
We also document this in the common errors, but apparently its Googlability is still not high enough. :)
Upvotes: 6