express middleware to rewrite a html web apps base tag in the index html. This is useful for serving web apps (like angular) from different base urls.

npm install express-webapp-host
68 downloads in the last week
92 downloads in the last month


Simple express middleware to host a static directory under a deeper url by rewriting the webapps index.html base tag


The index.html base tag must be present.

<meta charset="utf-8">
<base href='http://localhost:8888/' />
<title>My App</title>

It will be rewritten to the actual base path. Using the express example below when access via localhost it would rewrite it to:

<meta charset="utf-8">
<base href='http://localhost:8080/url/to/app/' />
<title>My App</title>

All url in the app should be relative paths.

usage with express

var webAppHost = require('express-webapp-host');
var express = require('express');
var app = express();

app.use('/url/to/app/', webAppHost.webApp('./path/to/app/on/disk'));


In combination with angular.js it is now possible to deep link when using Html5 Mode


Make sure all paths are relative unless you explicitly want to leave the sub location ('/url/to/app/' in the example above)

npm loves you