popojargo opened a new pull request #1120: Use relative pathname instead of static pathname for local replication URL: https://github.com/apache/couchdb-fauxton/pull/1120 <!-- Thank you for your contribution! Also remember, that CouchDB uses the Review-Then-Commit (RTC) model of code collaboration. Positive feedback is represented +1 from committers and negative is a -1. The -1 also means veto, and needs to be addressed to proceed. Once there are no objections, the PR can be merged by a CouchDB committer. See: http://couchdb.apache.org/bylaws.html#decisions for more info. --> ## Overview <!-- Please give a short brief for the pull request, what problem it solves or how it makes things better. --> When creating a replication using the new replication form, we used the window.location.pathname as the database name and the origin as the root url. Therefore, when we setup CouchDB on a subroute(relative url), local url is broken. Please file this form by replacing the Markdown comments with your text. If a section needs no action - remove it. ## Testing recommendations <!-- Describe how we can test your changes. Does it provides any behaviour that the end users could notice? --> I added a unit test. I also tested manually on an existing Couch configuration and one with a relative url. Relative url setup: I used a express pouchdb setup. 1. Create a folder 👍 2. In that folder create a package.json ```json { "name": "test", "version": "1.0.0", "description": "", "main": "test.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.16.3", "express-pouchdb": "^4.0.0", "morgan": "^1.4.0", "pouchdb": "^6.4.3" } } ``` 3. Create a test.js ```javascript var express = require('express') , app = express() , PouchDB = require('pouchdb') , logger = require('morgan') ; app.use(logger("tiny")); app.get('/', function (req, res, next) { res.send('Welcome Traveler! <a href="/db/_utils/">Fauxton?</a>'); }); //app.use('/express-pouchdb', require('express-pouchdb')(PouchDB)); app.use('/db', require('express-pouchdb')(PouchDB)); app.listen(3000); ``` 4. Install depencies with `npm install` 5. You need to edit `node_modules/express-pouchdb/lib/routes/fauxton.js` and change the exports for: ```javascript module.exports = function (app) { app.get('/_utils/', function (req, res) { // We want to force /_utils to /_utils/ as this is the CouchDB behavior // https://git.io/vDMOD#L78 // https://git.io/vDMOQ#L974 if (req.originalUrl === '/_utils') { res.redirect(301, '/_utils/'); } else { res.sendFile(path.normalize(FAUXTON_PATH + '/index.html')); } }); app.use('/_utils/', express.static(FAUXTON_PATH)); }; ``` 6. Make a fauxton release (`grunt release`) and copy the release to `node_modules/pouchdb-fauxton/www` 7. You need to replace in the index.html of the release (`dashboard` -> `./dashboard`) 8. You should be good 💃 ## GitHub issue number <!-- If this is a significant change, please file a separate issue at: https://github.com/apache/couchdb-fauxton/issues and include the number here and in commit message(s) using syntax like "Fixes #472" or "Fixes apache/couchdb#472". --> #1118 ## Related Pull Requests <!-- If your changes affects multiple components in different repositories please put links to those pull requests here. --> ## Checklist - [ ] Code is written and works correctly; - [ ] Changes are covered by tests; - [ ] Documentation reflects the changes; - [ ] Update [rebar.config.script](https://github.com/apache/couchdb/blob/master/rebar.config.script) with the correct tag once a new Fauxton release is made
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
