Open nolanlawson opened 7 years ago
From @thesli on October 28, 2014 16:2
And also to make the security tag work,it needs to change the permission url handling to realtive path
define("addons/permissions/resources", ["app", "api"], function(a, b) {
var c = b.addon();
return c.Security = Backbone.Model.extend({
defaults: {
admins: {
names: [],
roles: []
},
members: {
names: [],
roles: []
}
},
isNew: function() {
return !1
},
initialize: function(a, b) {
this.database = b.database
},
url: function() {
return "./" + this.database.safeID() + "/_security"
},
addItem: function(a, b, c) {
var d = this.get(c);
return d && d[b] ? d[b].indexOf(a) > -1 ? {
error: !0,
msg: "Role/Name has already been added"
} : (d[b].push(a), this.set(c, d)) : {
error: !0,
msg: "Section " + c + "does not exist"
}
}
})
return window.location.origin + "/" + this.database.safeID() + "/_security"
->
return "./" + this.database.safeID() + "/_security"
From @MichaelJCole on October 28, 2014 16:35
@thesli looks great! Thanks!
If no-one else wants to package this up, I'll make a new PR with this fix and the README changes around it.
From @nickcolley on October 28, 2014 21:58
Can we push this upstream?
From @MichaelJCole on November 8, 2014 21:35
Hi, I made these changes, did some testing, made some more changes, and made a PR in the Fauxton repo. https://github.com/pouchdb/couchdb-fauxton/pull/5
If accepted, there, I'll make a PR for here.
Cheers!
Mike
Looks like this was fixed in https://github.com/pouchdb/pouchdb-fauxton/pull/5 but it needs to be rebased on github.com/apache/couchdb-fauxton
Hi @nolanlawson, wanted to use PouchDB for another project and found this issue and my hacky old commit. lol.
Hey, could the base tag help here? I just don't know enough about PouchDB/CouchDB/Fauxton to make a real solution.
@MichaelJCole I think this issue has to be solved at the Fauxton level. It is possible. But we have never done any work in Fauxton to support it.
@MichaelJCole Not sure the base tag will help, as it says specifies the base URL to use for all relative URLs, the problem is Fauxton is specifying absolute url's :(
I've posted an issue to "couchdb-fauxton", it's been tagged "enhancement","help needed".
https://github.com/apache/couchdb-fauxton/issues/944
Not been able to use Fauxton inside a none root url, is a bit of a show stopper for me. It just doesn't feel right mixing database 'urls' with application / web urls.. Think of the confusion's if we created a database called img / css / assets etc.. :(
I'm pretty new to PouchDb/CouchDB, so I might not be the best person to help, but if there is nobody else who can, I'll give it a stab. My biggest problem is I'm not a massive Git user, last time I helped was with phantomjs-node
, I remember been out of my comfort zone, with all this git push, pull, etc.. :)
Downstream temporary patch would be much appreciated :)
This workaround fixed it for me (Express 4):
app.use('/example', ExampleRouter);
// Forward all unknown calls to PouchDb
app.use(function(req,res,next) {
return PouchDbRouter.handle(req, res, next);
});
One big caveat here is concerning naming. The name of the database cannot be the same as your other routes. If you look in the request log, Fauxton is making a lot of different requests so be careful! Possible solution is just to prefix your databases to avoid collision.
This commit in Fauxton https://github.com/apache/couchdb-fauxton/commit/8a3e520e17e2e79ee6015861f2592fadcb944558 should fix this. It would just require building the latest version of Fauxton for express-pouch
From @thesli on October 28, 2014 15:46
The host is no longer correct when you attach as middleware. In the case app.use('/db',...), a.host's value should be '/db/'
In require.js(build from apache/couchdb-fauxton:app/initialize.js.underscore)
The core/couchdbSession have the same issue of using "/_session" without refering correct location.
Also the clipboard part
The setting should be:
Please kindly rebuild the asset and serve the correct path.
Copied from original issue: pouchdb/express-pouchdb#124