Is it possible to set a base URL for NodeJS app?

By : Box9

I want to be able to host multiple NodeJS apps under the same domain, without using sub-domains (like instead of The problem is that I'm always typing the first part of the url e.g. "/reader" in Express/NodeJS.

How can I set up an Express app so that the base URL is

So instead of:

app.get("/myapp", function (req, res) {
   // can be accessed from

I can do:

// Some set-up
app.base = "/myapp"

app.get("/", function (req, res) {
   // can still be accessed from

I'd also like to configure Connect's staticProvider to behave the same way (right now it defaults to serving static files to or instead of

By : Box9


I was looking for this feature but for API routes, not for static files. What I did was that when I initialized the router, I added the mount path. So my configuration looks like this

//Default configuration
    app.set('json spaces',0);

    app.use('/api', app.router);        // 
By : Xerri

This video can help you solving your question :)
By: admin