Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Enable CORS and fauxton in pouchdb

I am creating a Cordova-Android app that runs express-pouch server in its backend. After going through all the issues and discussions, I tried to implement the

        overrideMode: {
         include: ['routes/fauxton']
         }

I got the fauxton but the configuration tab is blank , for which I am unable to enable the CORS. Then I tried to provide the config.json file enabling the CORS but still CORS was not activated. I tried to download the pouchdb-fauxton and did the npm link and also linked to the express-pouch but no luck.

config.json

 {
    "httpd": {
    "enable_cors": true
 },
 "cors": {
    "credentials": true,
    "methods": "GET, PUT, POST, HEAD, DELETE, OPTIONS",
    "origins": "*",
   "headers": "accept, authorization, content-type, origin, referer, 
   x-csrf-token"
  },
"httpd":{"Bind_address":"0.0.0.0"}
 }

Tried to use CORS package and tried to activate in express

main.js

   var argv = require('minimist')(process.argv.slice(2));
   var logLocation=argv.pouchlog; 
   var express = require('express');
   var app = express(); 
   var PouchDB = require('pouchdb');
   var cors = require('cors');

   let InMemPouchDB = PouchDB.defaults({db: require("memdown"), 
   migrate: true})
   let pouchHandle = require('express-pouchdb')(InMemPouchDB, 
   {mode:'minimumForPouchDB',configPath:'./config.json'});
   app.use("/",cors(corsConfig),pouchdbHandle);
      app.listen(3000);
      let db = new InMemPouchDB('test');
      db.changes({live:true}).on('change',console.log);

Tried to use add-cors-to-couchdb http://(ip of the device):3000/pos-demo

   Error: status 400 {"error":"bad_request","reason":"Only reserved document ids may start with underscore."}

at /home/hottab/.nvm/versions/node/v8.12.0/lib/node_modules/add-cors-to-couchdb/index.js:45:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)

Please can anyone help me with activating the CORS on the express-pouch server ? Any help will be greatly appreciated.

Comments