Express History API Fallback Middleware
JSON →express-history-api-fallback is an Express middleware designed to facilitate client-side routing for Single Page Applications (SPAs) that utilize the HTML5 History API. It addresses the common problem of 404 errors when a user directly navigates to a client-side route (e.g., `/app/dashboard`) that doesn't correspond to a static file on the server. The middleware ensures that the main `index.html` (or a specified entry point) is served instead. Currently stable at version 2.2.1, with its last known update around May 2017, the package maintains a highly focused approach. It explicitly serves the fallback only for GET/HEAD requests, for requests likely to be HTML, and only if no other static file or route matches. It leverages Express's `res.sendFile()` for efficient serving. While functional and widely used, its release cadence is dormant, indicating it's a mature, feature-complete library rather than one under active development.
Traffic · last 30 days ↑100% vs prev 7d
top countries 🇺🇸 United States · 🇨🇦 Canada · 🇫🇷 France · 🇩🇪 Germany · PT