/koa-history-api-fallback-middleware

koa history api fallback middleware

Primary LanguageJavaScript

koa-history-api-fallback-middleware

Installation

npm i -S koa-history-api-fallback-middleware

or

npm i -D koa-history-api-fallback-middleware

Example

const path = require('path')
const Koa = require('koa')
const app = new Koa()

const historyMiddleware = require('koa-history-api-fallback-middleware')({
  rewrites: [{
    from: /^\/lvchao\/view\/*/,
    // to: function({ parsedUrl, match, req }) {
    //   return '/static/index.html'
    // },
    to: '/static/index.html'
  }]
})

app.use(historyMiddleware)
app.use(require('koa-static')(path.resolve(process.cwd(), './public')))

more