egg-rewriter
v1.0.4
Published
url rewrite for eggjs
Downloads
8
Readme
egg-rewriter
Install
$ npm i egg-rewriter --save
# or
$ yarn add egg-rewriter
Usage
// {app_root}/config/plugin.js
exports.rewriter = {
enable: true,
package: 'egg-rewriter',
};
Configuration
// {app_root}/config/config.default.js
exports.rewriter = {
// 默认重写到 /index.html
index: '/index.html',
// 打印日志
verbose: true,
// 白名单正则,默认 /\/api/gi, 符合白名单规则的url一律不重写
whiteList: /\/api/gi,
// 自定义url重写规则,覆盖 index
rewriteRule: [
{ from: /\/admin/, to: '/admin.html' },
{ from: /\/login/, to: '/login.html' },
],
};
see config/config.default.js for more detail.
Example
Questions & Suggestions
Please open an issue here.