1.0.0 • Published 7 years ago

@sidvind/serve-rewrite v1.0.0

Weekly downloads
11
License
MIT
Repository
-
Last release
7 years ago

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.

1.0.0

7 years ago