connect-history-api-fallback连接历史接口失败回调

摘录于https://www.npmjs.com/package/connect-history-api-fallback

安装

npm install --save connect-history-api-fallback

示例

var express = require('express');
var history = require('connect-history-api-fallback');
var app = express();
app.use(history());

参数

Override the index (default /index.html)

history({
  index: '/default.html'
});

Override the index when the request url matches a regex pattern.

history({
  rewrites: [
    { from: /\/soccer/, to: '/soccer.html'}
  ]
});

This middleware does not log any information by default. If you wish to activate logging, then you can do so via the verbose option or by specifying a logger function.

history({
  verbose: true,
   logger: console.log.bind(console)
});

Override the default Accepts: headers that are queried when matching HTML content requests (Default: ['text/html', '/']).

history({
  htmlAcceptHeaders: ['text/html', 'application/xhtml+xml']
})
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容