{
  "_id": "express-history-api-fallback",
  "maintainers": [
    {
      "name": "seb",
      "email": "seb@ninja.sg"
    }
  ],
  "keywords": [
    "express",
    "html5",
    "history api",
    "fallback",
    "spa",
    "middleware",
    "connect",
    "pushstate",
    "popstate",
    "single page app",
    "router",
    "client side"
  ],
  "dist-tags": {
    "latest": "2.2.1"
  },
  "author": {
    "name": "Sebastiaan Deckers",
    "email": "sebdeckers83@gmail.com"
  },
  "_rev": "8-749c1bdf90b04dfe94a18f84d685a6ae",
  "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
  "readme": "# express-history-api-fallback\nA tiny, accurate, fast Express middleware for single page apps with client side routing.\n\n[![Build Status](https://travis-ci.org/cbas/express-history-api-fallback.svg?branch=master)](https://travis-ci.org/cbas/express-history-api-fallback)\n[![codecov.io](https://codecov.io/github/cbas/express-history-api-fallback/coverage.svg?branch=master)](https://codecov.io/github/cbas/express-history-api-fallback?branch=master)\n\n[![NPM](https://nodei.co/npm/express-history-api-fallback.png)](https://www.npmjs.com/package/express-history-api-fallback)\n\nWorks as a middleware for Express. Can be used as either an application middleware or a router middleware.\n\n```js\nimport fallback from 'express-history-api-fallback'\nimport express from 'express'\nconst app = express()\nconst root = `${__dirname}/public`\napp.use(express.static(root))\napp.use(fallback('index.html', { root }))\n```\nOr in ECMAScript 5:\n```js\nvar fallback = require('express-history-api-fallback')\nvar express = require('express')\nvar app = express()\nvar root = __dirname + '/public'\napp.use(express.static(root))\napp.use(fallback('index.html', { root: root }))\n```\n\n## fallback(path[, options])\nReturns a middleware for use by Express applications and routers.\n\nArguments are passed to [res.sendFile()](http://expressjs.com/api.html#res.sendFile) in `express@>=v4.8.0`, or [res.sendfile()](http://expressjs.com/en/3x/api.html#res.sendfile) otherwise.\n\nAbsolute path:\n```js\napp.use(fallback(__dirname + '/dist/app.html'))\n```\nRelative path:\n```js\napp.use(fallback('dist/app.html', { root: __dirname }))\n```\n\n### path\nLocation of the HTML file containing single page app entry point.\n\nUnless the `root` option is set in the `options` object, `path` must be an absolute path of the file.\n\n### options\nValid options are `maxAge`, `root`, `lastModified`, `headers`, and `dotfiles`. See [Response.sendFile()](http://expressjs.com/api.html#res.sendFile) for details. Note that only `maxAge` and `root` are supported with `express@<4.8`.\n\n## But doesn't this already exist?\nYes, but this implementation is much better.\n\n- **Only for GET (and HEAD) requests**: The fallback should not serve your `index.html` for `POST` or other requests.\n- **Only for HTML requests**: Never serve mistakenly for JS or CSS or image or other static file requests. Less debugging headaches.\n- **Only when needed**: Serve the fallback only when the file is missing.\n- **High performance**: Let `res.sendFile()` in Express `>=4.8.0` do the heavy lifting of serving the file.\n- **Minimal code**: Just a few lines. No magic. No complexity.\n\nSee the blog post [\"Single Page App Routing with Express & Node.js\"](https://ninja.sg/spa-router-fallback/) for an overview of the problems with alternative middlewares.\n",
  "repository": {
    "type": "git",
    "url": "git+https://gitlab.com/sebdeckers/express-history-api-fallback.git"
  },
  "users": {
    "amongiants": true
  },
  "bugs": {
    "url": "https://gitlab.com/sebdeckers/express-history-api-fallback/issues"
  },
  "license": "ISC",
  "versions": {
    "1.0.0": {
      "name": "express-history-api-fallback",
      "version": "1.0.0",
      "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
      "main": "./dist",
      "scripts": {
        "start": "npm run start-audit & npm run start-tdd",
        "start-audit": "watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit",
        "start-tdd": "watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd",
        "test": "npm run test-audit & npm run test-tdd",
        "test-audit": "node-license-validator",
        "test-tdd": "standard & npm run coverage",
        "coverage": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
        "prepublish": "npm run clean && npm test && npm run build",
        "clean": "rimraf dist",
        "build": "mkdirp dist && babel lib --out-file dist/index.js",
        "codecov": "cat coverage/coverage.json | codecov"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/cbas/express-history-api-fallback.git"
      },
      "keywords": [
        "express",
        "html5",
        "history api",
        "fallback",
        "spa",
        "middleware",
        "connect",
        "pushstate",
        "popstate",
        "single page app",
        "router",
        "client side"
      ],
      "author": {
        "name": "Sebastiaan Deckers",
        "email": "seb@ninja.sg"
      },
      "license": "ISC",
      "bugs": {
        "url": "https://github.com/cbas/express-history-api-fallback/issues"
      },
      "homepage": "https://github.com/cbas/express-history-api-fallback#readme",
      "devDependencies": {
        "babel": "^5.8.29",
        "babel-eslint": "^4.1.3",
        "chai": "^3.4.0",
        "codecov.io": "^0.1.6",
        "express": "^4.13.3",
        "isparta": "^3.1.0",
        "mkdirp": "^0.5.1",
        "mocha": "^2.3.3",
        "node-license-validator": "^1.2.1",
        "rimraf": "^2.4.3",
        "sinon": "^1.17.2",
        "sinon-chai": "^2.8.0",
        "standard": "^5.3.1",
        "watch-spawn": "^1.0.6"
      },
      "standard": {
        "parser": "babel-eslint"
      },
      "gitHead": "55880e14ff0624bfb4fd23a1a95c841f90050110",
      "_id": "express-history-api-fallback@1.0.0",
      "_shasum": "b1dc9be4d3d1c833d505af1c7b95fbd956e2ba98",
      "_from": ".",
      "_npmVersion": "2.14.7",
      "_nodeVersion": "4.2.1",
      "_npmUser": {
        "name": "seb",
        "email": "seb@ninja.sg"
      },
      "dist": {
        "shasum": "b1dc9be4d3d1c833d505af1c7b95fbd956e2ba98",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/express-history-api-fallback/-/express-history-api-fallback-1.0.0.tgz",
        "integrity": "sha512-2x+7uLoWz3Bd17v4rS0jTRCoghH1cSJpJkNtlzZnVfLT+yHVf4JPUzlsVxWWGj0vJDU36ZTEU+wxWu34DHBu9A==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEYCIQD4Sj5b04gkDa19NEA5W6YzUWVO1WCvKcFqh2xlhG3tfgIhAOGIPfwl5K7V/4RbTKqY2h3X44KF/IJ2fuTo+4TQD6Lj"
          }
        ]
      },
      "maintainers": [
        {
          "name": "seb",
          "email": "seb@ninja.sg"
        }
      ]
    },
    "2.0.0": {
      "name": "express-history-api-fallback",
      "version": "2.0.0",
      "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
      "main": "./dist",
      "scripts": {
        "start": "npm run start-audit & npm run start-tdd",
        "start-audit": "watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit",
        "start-tdd": "watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd",
        "test": "npm run test-audit & npm run test-tdd",
        "test-audit": "node-license-validator",
        "test-tdd": "standard & npm run coverage",
        "coverage": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
        "prepublish": "npm run clean && npm test && npm run build",
        "clean": "rimraf dist",
        "build": "mkdirp dist && babel lib --out-file dist/index.js",
        "codecov": "cat coverage/coverage.json | codecov"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/cbas/express-history-api-fallback.git"
      },
      "keywords": [
        "express",
        "html5",
        "history api",
        "fallback",
        "spa",
        "middleware",
        "connect",
        "pushstate",
        "popstate",
        "single page app",
        "router",
        "client side"
      ],
      "author": {
        "name": "Sebastiaan Deckers",
        "email": "seb@ninja.sg"
      },
      "license": "ISC",
      "bugs": {
        "url": "https://github.com/cbas/express-history-api-fallback/issues"
      },
      "homepage": "https://github.com/cbas/express-history-api-fallback#readme",
      "devDependencies": {
        "babel": "^5.8.29",
        "babel-eslint": "^4.1.3",
        "chai": "^3.4.0",
        "codecov.io": "^0.1.6",
        "isparta": "^3.1.0",
        "mkdirp": "^0.5.1",
        "mocha": "^2.3.3",
        "node-license-validator": "^1.2.1",
        "rimraf": "^2.4.3",
        "sinon": "^1.17.2",
        "sinon-chai": "^2.8.0",
        "standard": "^5.3.1",
        "watch-spawn": "^1.0.6"
      },
      "standard": {
        "parser": "babel-eslint"
      },
      "gitHead": "badf8965b7ebffd29385f194d031e031f333b6cc",
      "_id": "express-history-api-fallback@2.0.0",
      "_shasum": "c7a47ffe30ee1a1ff6cf54c2bdc319d634991b2e",
      "_from": ".",
      "_npmVersion": "2.14.7",
      "_nodeVersion": "4.2.1",
      "_npmUser": {
        "name": "seb",
        "email": "seb@ninja.sg"
      },
      "dist": {
        "shasum": "c7a47ffe30ee1a1ff6cf54c2bdc319d634991b2e",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/express-history-api-fallback/-/express-history-api-fallback-2.0.0.tgz",
        "integrity": "sha512-OqExYgBVw9XXmmP9jqmJD0fyt37PcWE9gvyRdGC7SGlYWidPPkOtA/AnshS8jp9OaOU0FnDSy0HsZga7EhQt4w==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIHu58TFExWspxoc/Ikcw8qh1yTz8gCwgHSdia31rpiY7AiEAq8SF4JQ1sN+CsZHMJz7vMpBrWcoW87td4HtzFfNI6Fg="
          }
        ]
      },
      "maintainers": [
        {
          "name": "seb",
          "email": "seb@ninja.sg"
        }
      ]
    },
    "2.1.0": {
      "name": "express-history-api-fallback",
      "version": "2.1.0",
      "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
      "main": "./dist",
      "scripts": {
        "start": "npm run start-audit & npm run start-tdd",
        "start-audit": "watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit",
        "start-tdd": "watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd",
        "test": "npm run test-audit & npm run test-tdd",
        "test-audit": "node-license-validator",
        "test-tdd": "standard & npm run coverage",
        "coverage": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
        "prepublish": "npm run clean && npm test && npm run build",
        "clean": "rimraf dist",
        "build": "mkdirp dist && babel lib --out-file dist/index.js",
        "codecov": "cat coverage/coverage.json | codecov"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/cbas/express-history-api-fallback.git"
      },
      "keywords": [
        "express",
        "html5",
        "history api",
        "fallback",
        "spa",
        "middleware",
        "connect",
        "pushstate",
        "popstate",
        "single page app",
        "router",
        "client side"
      ],
      "author": {
        "name": "Sebastiaan Deckers",
        "email": "seb@ninja.sg"
      },
      "license": "ISC",
      "bugs": {
        "url": "https://github.com/cbas/express-history-api-fallback/issues"
      },
      "homepage": "https://github.com/cbas/express-history-api-fallback#readme",
      "devDependencies": {
        "babel": "^5.8.29",
        "babel-eslint": "^4.1.3",
        "chai": "^3.4.0",
        "codecov.io": "^0.1.6",
        "isparta": "^3.1.0",
        "mkdirp": "^0.5.1",
        "mocha": "^2.3.3",
        "node-license-validator": "^1.2.1",
        "rimraf": "^2.4.3",
        "sinon": "^1.17.2",
        "sinon-chai": "^2.8.0",
        "standard": "^5.3.1",
        "watch-spawn": "^1.0.6"
      },
      "standard": {
        "parser": "babel-eslint"
      },
      "gitHead": "2616ff8577afc8fcb30008dc61f0b54175eece50",
      "_id": "express-history-api-fallback@2.1.0",
      "_shasum": "3bed00cf8a3a3baa85c1d43357c28762eb6185ac",
      "_from": ".",
      "_npmVersion": "3.10.10",
      "_nodeVersion": "7.2.1",
      "_npmUser": {
        "name": "seb",
        "email": "sebdeckers83@gmail.com"
      },
      "dist": {
        "shasum": "3bed00cf8a3a3baa85c1d43357c28762eb6185ac",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/express-history-api-fallback/-/express-history-api-fallback-2.1.0.tgz",
        "integrity": "sha512-/hFP41m4SBwfzDFpLepN17fIP8wTqBJVm5/RozAFIJYSkpIGozY7Y3DkjkzI5+eZW4VVUsVsfQoPzgNF4IsLOQ==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIGvCql7NotYndjRxCzCirHVfMkdK5IkiI4iwC2C7dtSNAiBRfUeEkQp0IwO3IgPktYTCacvdErLd26L3ZsIpF9abiQ=="
          }
        ]
      },
      "maintainers": [
        {
          "name": "seb",
          "email": "seb@ninja.sg"
        }
      ],
      "_npmOperationalInternal": {
        "host": "packages-12-west.internal.npmjs.com",
        "tmp": "tmp/express-history-api-fallback-2.1.0.tgz_1481792805878_0.715644568670541"
      }
    },
    "2.2.0": {
      "name": "express-history-api-fallback",
      "version": "2.2.0",
      "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
      "main": "./dist",
      "scripts": {
        "start": "npm run start-audit & npm run start-tdd",
        "start-audit": "watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit",
        "start-tdd": "watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd",
        "test": "npm run test-audit & npm run test-tdd",
        "test-audit": "node-license-validator",
        "test-tdd": "standard & npm run coverage",
        "coverage": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
        "prepublish": "npm run clean && npm test && npm run build",
        "clean": "rimraf dist",
        "build": "mkdirp dist && babel lib --out-file dist/index.js",
        "codecov": "cat coverage/coverage.json | codecov"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/cbas/express-history-api-fallback.git"
      },
      "keywords": [
        "express",
        "html5",
        "history api",
        "fallback",
        "spa",
        "middleware",
        "connect",
        "pushstate",
        "popstate",
        "single page app",
        "router",
        "client side"
      ],
      "author": {
        "name": "Sebastiaan Deckers",
        "email": "seb@ninja.sg"
      },
      "license": "ISC",
      "bugs": {
        "url": "https://github.com/cbas/express-history-api-fallback/issues"
      },
      "homepage": "https://github.com/cbas/express-history-api-fallback#readme",
      "devDependencies": {
        "babel": "^5.8.29",
        "babel-eslint": "^4.1.3",
        "chai": "^3.4.0",
        "codecov.io": "^0.1.6",
        "isparta": "^3.1.0",
        "mkdirp": "^0.5.1",
        "mocha": "^2.3.3",
        "node-license-validator": "^1.2.1",
        "rimraf": "^2.4.3",
        "sinon": "^1.17.2",
        "sinon-chai": "^2.8.0",
        "standard": "^5.3.1",
        "watch-spawn": "^1.0.6"
      },
      "standard": {
        "parser": "babel-eslint"
      },
      "gitHead": "288494720f2d164371d216c813d130b33a9527fb",
      "_id": "express-history-api-fallback@2.2.0",
      "_shasum": "3dbcb7423afa0e6ff94249112e332999c634a82c",
      "_from": ".",
      "_npmVersion": "4.2.0",
      "_nodeVersion": "7.10.0",
      "_npmUser": {
        "name": "seb",
        "email": "sebdeckers83@gmail.com"
      },
      "dist": {
        "shasum": "3dbcb7423afa0e6ff94249112e332999c634a82c",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/express-history-api-fallback/-/express-history-api-fallback-2.2.0.tgz",
        "integrity": "sha512-6k3G+FHxs1XzfS1APG/0qoL2Ze6MrkiPl+6CfDOrZPdLKojUrTfbR2r4ZW9MTJg0rqcB2E88dPGWSAsAx4uzBQ==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIA3/rm18c0Uz/UZLfKXaD8UlstECNmxTRHF33nJZLJ11AiBhimNMdgzLDBkRtkJ0jAqwXyXrcbF3LLig3JIlrYXhnw=="
          }
        ]
      },
      "maintainers": [
        {
          "name": "seb",
          "email": "seb@ninja.sg"
        }
      ],
      "_npmOperationalInternal": {
        "host": "packages-12-west.internal.npmjs.com",
        "tmp": "tmp/express-history-api-fallback-2.2.0.tgz_1495035391992_0.7154691573232412"
      }
    },
    "2.2.1": {
      "name": "express-history-api-fallback",
      "version": "2.2.1",
      "description": "Simple fallback for Express-served single page apps that use the HTML5 History API for client side routing.",
      "main": "./dist",
      "scripts": {
        "start": "npm run start-audit & npm run start-tdd",
        "start-audit": "watch-spawn --initial --quiet --pattern 'package.json' npm run test-audit",
        "start-tdd": "watch-spawn --initial --quiet --pattern '{lib,test}/**/*.js' npm run test-tdd",
        "test": "npm run test-audit & npm run test-tdd",
        "test-audit": "node-license-validator",
        "test-tdd": "standard & npm run coverage",
        "coverage": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
        "prepublish": "npm run clean && npm test && npm run build",
        "clean": "rimraf dist",
        "build": "mkdirp dist && babel lib --out-file dist/index.js",
        "codecov": "cat coverage/coverage.json | codecov"
      },
      "repository": {
        "type": "git",
        "url": "git+https://gitlab.com/sebdeckers/express-history-api-fallback.git"
      },
      "keywords": [
        "express",
        "html5",
        "history api",
        "fallback",
        "spa",
        "middleware",
        "connect",
        "pushstate",
        "popstate",
        "single page app",
        "router",
        "client side"
      ],
      "author": {
        "name": "Sebastiaan Deckers",
        "email": "sebdeckers83@gmail.com"
      },
      "license": "ISC",
      "bugs": {
        "url": "https://gitlab.com/sebdeckers/express-history-api-fallback/issues"
      },
      "homepage": "https://gitlab.com/sebdeckers/express-history-api-fallback#readme",
      "devDependencies": {
        "babel": "^5.8.29",
        "babel-eslint": "^4.1.3",
        "chai": "^3.4.0",
        "codecov.io": "^0.1.6",
        "isparta": "^3.1.0",
        "mkdirp": "^0.5.1",
        "mocha": "^2.3.3",
        "node-license-validator": "^1.2.1",
        "rimraf": "^2.4.3",
        "sinon": "^1.17.2",
        "sinon-chai": "^2.8.0",
        "standard": "^5.3.1",
        "watch-spawn": "^1.0.6"
      },
      "standard": {
        "parser": "babel-eslint"
      },
      "gitHead": "13aa6fb15ddd6d39dc5e623937256c2e789dcc53",
      "_id": "express-history-api-fallback@2.2.1",
      "_shasum": "3a2ad27f7bebc90fc533d110d7c6d83097bcd057",
      "_from": ".",
      "_npmVersion": "4.2.0",
      "_nodeVersion": "7.10.0",
      "_npmUser": {
        "name": "seb",
        "email": "sebdeckers83@gmail.com"
      },
      "dist": {
        "shasum": "3a2ad27f7bebc90fc533d110d7c6d83097bcd057",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz",
        "integrity": "sha512-swxwm3aP8vrOOvlzOdZvHlSZtJGwHKaY94J6AkrAgCTmcbko3IRwbkhLv2wKV1WeZhjxX58aLMpP3atDBnKuZg==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIHAJnaPnKtJ/RNmJxbbEfcS4A4zVcH5fxZT7vjKPC+4zAiBrveZz4rCYVNxclhTo4sp4gbU6x1rWg8EVn8vy2eu/vQ=="
          }
        ]
      },
      "maintainers": [
        {
          "name": "seb",
          "email": "seb@ninja.sg"
        }
      ],
      "_npmOperationalInternal": {
        "host": "packages-12-west.internal.npmjs.com",
        "tmp": "tmp/express-history-api-fallback-2.2.1.tgz_1495035767934_0.38333291513845325"
      }
    }
  },
  "name": "express-history-api-fallback",
  "time": {
    "modified": "2026-06-17T06:42:41.836Z",
    "created": "2015-10-26T09:32:12.941Z",
    "1.0.0": "2015-10-26T09:32:12.941Z",
    "2.0.0": "2015-10-26T11:29:56.829Z",
    "2.1.0": "2016-12-15T09:06:46.103Z",
    "2.2.0": "2017-05-17T15:36:32.294Z",
    "2.2.1": "2017-05-17T15:42:48.177Z"
  },
  "readmeFilename": "README.md",
  "homepage": "https://gitlab.com/sebdeckers/express-history-api-fallback#readme"
}