@sidvind/serve-rewrite

1.0.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i @sidvind/serve-rewrite

    Weekly Downloads

    13

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.59 kB

    Total Files

    11

    Last publish

    Collaborators

    • ext