@sidvind/serve-rewrite
v1.0.0
Published
connect/express middleware for rewriting all urls
Readme
Connect/Express middleware for rewriting all urls.
When writing single-page applications with HTML5 history API it is desirable to
rewrite all urls back to the application, e.g. index.html.
This middleware will do an internal redirect with the rewritten URL.
Usage
const serveRewrite = require('@sidvind/serve-rewrite');
const middleware = [
serveRewrite('/index.html', {
ignore: [
'^/(assets/|favicon)', /* do not rewrite assets and favicon */
],
}),
serveStatic('public'), /* serve files from public folder */
];Options
ignore
RegExp | RegExp[] of URL patterns to ignore (i.e. not rewrite).
debug
boolean. If true debugging information will be written to stdout.
