Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
express-history-api-fallback
Advanced tools
Readme
A tiny, accurate, fast Express middleware for single page apps with client side routing.
Works as a middleware for Express. Can be used as either an application middleware or a router middleware.
import fallback from 'express-history-api-fallback'
import express from 'express'
const app = express()
const root = `${__dirname}/public`
app.use(express.static(root))
app.use(fallback('index.html', { root }))
Or in ECMAScript 5:
var fallback = require('express-history-api-fallback')
var express = require('express')
var app = express()
var root = __dirname + '/public'
app.use(express.static(root))
app.use(fallback('index.html', { root: root }))
Returns a middleware for use by Express applications and routers.
Arguments are passed to res.sendFile() in express@>=v4.8.0
, or res.sendfile() otherwise.
Absolute path:
app.use(fallback(__dirname + '/dist/app.html'))
Relative path:
app.use(fallback('dist/app.html', { root: __dirname }))
Location of the HTML file containing single page app entry point.
Unless the root
option is set in the options
object, path
must be an absolute path of the file.
Valid options are maxAge
, root
, lastModified
, headers
, and dotfiles
. See Response.sendFile() for details. Note that only maxAge
and root
are supported with express@<4.8
.
Yes, but this implementation is much better.
index.html
for POST
or other requests.res.sendFile()
in Express >=4.8.0
do the heavy lifting of serving the file.See the blog post "Single Page App Routing with Express & Node.js" for an overview of the problems with alternative middlewares.
FAQs
Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.
The npm package express-history-api-fallback receives a total of 93,762 weekly downloads. As such, express-history-api-fallback popularity was classified as popular.
We found that express-history-api-fallback demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.