I have several applications that I am trying to combine into one โsetโ: 2 applications are autonomous, one is simply an auth layer (using everyauth for FB Connect). I want to configure it like this:
- / - (home) application list
- / auth - login for any application
- / app1 - requires login through / auth to access
- / app2 - (same)
I considered leaving app1 and app2 autonomous, with the top layer being a proxy server, but I think it would be difficult to separate the auth system between them. Virtualhosts (via Connect) can work, but I donโt necessarily need a DNS'd subdomain for each of them. Therefore, instead, I would like the main application to be an auth layer and the rest to be โmountedโ into it, with the base path set in each application being subpath. (The base path is mentioned in the Guide expression, but not documented.)
They all use MongoDB, the auth level uses connect-mongodb for sessions, so I hope they can share the entire authentication / session level between them.
In another thread, How to exchange sessions in installed express applications , writes Stephen,
I have a rather complicated express application for web applications, which is divided into several auxiliary applications, which are also express applications (using app.use ()) ...
So how to use app.use() to mount a sub application? I was just trying to use var subApp = require('./subapp/app.js') , while listen() only works in a sub-application when ! module.parent ! module.parent (and not as a sub-application) ... but this seems to load all the sub-application paths directly into the parent application. I tried setting basepath with app.set('basepath', '/subapp/') , app.basepath = '/subapp/' , etc. Both in the sub-application itself and in the parent application, but this does not seem to have any effect.
Installing such applications makes it incredibly flexible, but it's unclear how to do it ... any advice would be greatly appreciated! (And I'm glad to share the lessons from my everyauth implementation if someone struggles with this.)
thebuckst0p Dec 15 '11 at 1:40 2011-12-15 01:40
source share