Sync gateway returns 'bad json' when retrieving documents


#1

Hi I am new at this forum and I have encountered some problems configuring the couchbase sync gateway and the couchbase server.
I have an instance of “couchbase server” and an instance of “Couchbase SG” both running with docker, and the gateway is configured to rely on the server as explained in this tutorial (https://hub.docker.com/r/couchbase/sync-gateway/) “Running with couchbase server”.
Here there is my configuration:
{
“adminInterface”: “:8095”,
“log”: [""],
“databases”: {
“staging”: {
“server”: “http://172.18.0.2:8091”,
“bucket”: “test-bucket”,
“username”: “sync_gateway”,
“password”: “xxxx”,
“enable_shared_bucket_access”: true,
“import_docs”: “continuous”,
“users”: {
“GUEST”: {
“disabled”: false,
“admin_channels”: ["
"]
}
},
“sync”: function (doc, oldDoc) { if (doc.sdk) { channel(doc.sdk); } }
}
},
“CORS”: {
“Origin”: [""],
“LoginOrigin”: ["
"],
“Headers”: [“Content-Type”],
“MaxAge”: 17280000
}
}

The configuration and the connection are working fine so my gateway can successfully connect to the server.
But when I am trying to put sometheing in the database, the response from my client after the request is BAD JSON.
BUT! if go to my couchbase db console I can see the document I have just created. So it seems that the answer of the gateway is not encoded in the right way.

Also from the gateway logs i get:
2018-05-31T16:01:22.735Z WARNING: Couldn’t parse JSON in HTTP request: EOF – db.ReadJSONFromMIME() at attachment.go:238

my client code:

var PouchDB = require("pouchdb-node");

const url = ‘http://:8095/test-bucket’;

let db = new PouchDB(url);

db.allDocs()
.then(function (docs) {
console.log(‘docs’, docs);
}, function (err) {
console.log(‘error’, err);
})