pouchdb / pouchdb-server

CouchDB-compatible server built on PouchDB and Node
Apache License 2.0
948 stars 154 forks source link

http-pouchdb example for express-pouchdb doesn't work without a trailing slash on the URL #379

Open maxkfranz opened 5 years ago

maxkfranz commented 5 years ago

The example in the readme:

If you want express-pouchdb to proxy requests to another CouchDB-style HTTP API, you can use http-pouchdb:

var TempPouchDB = require('http-pouchdb')(PouchDB, 'http://localhost:5984');
app.use('/db', require('express-pouchdb')(TempPouchDB));

Running the example verbatim, localhost:5984 does not work. However, localhost:5984/ does work.

See this line: https://github.com/pouchdb/pouchdb-server/blob/4.1.0/packages/node_modules/http-pouchdb/lib/index.js#L25

It should probably be using url.resolve() to safely build the final URL.