Connect History API Fallback Middleware

JSON →
library 2.0.0 ·javascript
verified May 27, 2026

connect-history-api-fallback is a robust middleware designed for Single Page Applications (SPAs) leveraging the HTML5 History API. It addresses the common challenge where direct access to client-side routes (e.g., `/about` or `/users/123`) or page refreshes result in a 404 "Not Found" error from the web server, as these paths do not correspond to physical files. The middleware intercepts such requests, identifies those that accept `text/html` and are not direct file requests (by default, paths containing a dot), and then rewrites the request URL to a specified index file, typically `/index.html`. This allows the SPA's client-side router to take over and render the correct view. The current stable version is 2.0.0. While there isn't a strict release cadence, updates generally address compatibility, performance, or new configuration options. Key differentiators include its configurable `index` path, powerful `rewrites` option supporting both static strings and dynamic functions based on request context, and fine-grained control over accepted HTML headers and dot-file handling. It seamlessly integrates with Connect and Express-based Node.js servers.

total hits 34
actors 7 distinct systems
last hit 2d ago human
ByteDance
13
MetaBot
4
GPTBot
2
Script
1
Search engines
1
Humans
5

top countries 🇸🇬 Singapore · 🇺🇸 United States · 🇩🇪 Germany · 🇨🇦 Canada · VN