I created a local CouchDB database and I would like to replicate it to a PouchDB database using JavaScript on a web page running on a local hosting.
With the code below, I get this error:
The origin of http://localhost not valid with Access-Control-Allow-Origin.
Since http:// is removed from REMOTE, I do not get an error, but no documents are displayed as replicated.
Looking at IndexedDB databases from Chrome DevTools, I see that the database was created (but has no documents).
Works in Chrome 29.0.1535.2 canary.
Can I do this locally or do I need to set up a remote CouchDB database and enable CORS (according to Docs Docs )?
var REMOTE = 'http://127.0.0.1:5984/foo'; var LOCAL = 'idb://foo'; Pouch(LOCAL, function(error, pouchdb){ if (error) { console.log("Error: ", error); } else { var db = pouchdb; Pouch.replicate(REMOTE, LOCAL, function (error, changes) { if (error) { console.log('Error: ', error); } else { console.log('Changes: ', changes); db.allDocs({include_docs: true}, function(error, docs) { console.log('Rows: ', docs.rows); }); }}); } });
Sam dutton
source share