Proxy-plugin-redirect
A dalao-proxy plugin for request redirect.
Awesome plugin for debugging the online program locally.
Usage
1. Global Install
Install dalao-proxy
cli first
npm install -g dalao-proxy
Add plugin
$ dalao-proxy add-plugin @calvin_von/proxy-plugin-redirect
> @calvin_von/proxy-plugin-redirect Install complete
Add config
"redirect": [
{
"from": "http://www.example.com/(app|\\d+).(\\w+.)?js",
"to": "http://localhost:8000/$1.js"
},
{
"from": "/(api/.+)",
"to": "http://localhost:8000/$1"
}
]
Start proxy
$ dalao-proxy start
Redirect config table:
┌────────────────────────────────────────────┬─────────────────────────────┐
│ From │ To │
├────────────────────────────────────────────┼─────────────────────────────┤
│ http://www.example.com/(app|\d+).(\w+.)?js │ http://localhost:8000/$1.js │
├────────────────────────────────────────────┼─────────────────────────────┤
│ /(api/.+) │ http://localhost:8000/$1 │
└────────────────────────────────────────────┴─────────────────────────────┘
2. Local Install
$ npm install -D dalao-proxy
$ npm install -D @calvin_von/proxy-plugin-redirect
Generate config json file
$ npx dalao-proxy init
Add plugin in config json file
{
"plugins": [
"@calvin_von/proxy-plugin-redirect"
]
}
package.json
{
"scripts": {
"proxy": "dalao-proxy start"
}
}
Start proxy
$ npm run proxy
more docs about dalao-proxy
, see CalvinVon/dalao-proxy on Github.