# koa2-connect-history-api-fallback

> Fallback to index.html for applications that are using the HTML 5 history API

Latest version **0.1.3** (published 2020-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa2-connect-history-api-fallback
pnpm add koa2-connect-history-api-fallback
yarn add koa2-connect-history-api-fallback
bun add koa2-connect-history-api-fallback
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2020-09-21 |
| First published | 2017-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 184.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Shen7 |
| Maintainers | shen7 |
| Keywords | koa2, history-api, connect-history-api-fallback, vue2, vue-router:history, koa2 vue-router |

## Links

- npm: https://www.npmjs.com/package/koa2-connect-history-api-fallback
- Repository: https://github.com/ishen7/koa2-connect-history-api-fallback
- Homepage: https://github.com/ishen7/koa2-connect-history-api-fallback#readme
- Issues: https://github.com/ishen7/koa2-connect-history-api-fallback/issues
- npm.io page: https://npm.io/package/koa2-connect-history-api-fallback

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.1.3 (latest) — 2020-09-21
- 0.1.2 — 2019-04-20
- 0.1.1 — 2018-12-29
- 0.1.0 — 2018-12-25
- 0.0.6 — 2017-09-30
- 0.0.5 — 2017-09-18
- 0.0.3 — 2017-09-11
- 0.0.2 — 2017-09-11
- 0.0.1 — 2017-09-11

## README

# README.md

koa2的一个中间件，用于处理vue-router使用history模式返回index.html，让koa2支持SPA应用程序。 \
我只是一个搬运工，让它兼容Koa2而已。详细说明请到原作者项目库查看\
[bripkens作者的connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback)

## Install

```bash
$ npm install --save 'koa2-connect-history-api-fallback'
```

## Use

在原作者的使用方法下增加了白名单选项，原作者的插件默认会将所有的请求都指向到index.html，这样可能就会导致项目内其他路由也被指向到index.html
使用方法如下：

```javascript
const Koa = require('koa');
const { historyApiFallback } = require('koa2-connect-history-api-fallback');
// 或者当你使用 ES6 语法，你可以这样
import { historyApiFallback } from 'koa2-connect-history-api-fallback';
// 或者
import historyApiFallback from 'koa2-connect-history-api-fallback';

const app = new Koa();

// handle fallback for HTML5 history API
app.use(historyApiFallback({ whiteList: ['/api'] }));

// other middlewares
app.use(...);
```

## Example
```javascript
const Koa = require('koa');

// require 'koa2-connect-history-api-fallback' middleware
const { historyApiFallback } = require('koa2-connect-history-api-fallback');

// create app
const app = new Koa();

// use historyApiFallback
app.use(historyApiFallback());

// other middlewares
app.use(...);

```

# LICENSE

Follow [MIT License](/LICENSE)

---
_Source: https://npm.io/package/koa2-connect-history-api-fallback · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
