Package Exports
- nice-proxy
- nice-proxy/dist/lib/use-nice-proxy.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nice-proxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
nice-proxy
刚起步的项目,功能并不是很完善,欢迎提意见。
每次切换代理难道都要重启任务吗?大可不必!
安装
yarn add nice-proxy
使用
务必先初始化
npx nice-proxy init
该命令会在项目根目录生成一个nice-proxy文件夹。
其中proxy-list.json为代理列表文件。proxy-config.json为你当前使用的代理配置。
配置 webpack-dev-server
vue-cli
如果你使用的是vue-cli创建的项目,那么在你的vue.config.js文件里这么去写。
const { useNiceProxy } = require("nice-proxy");
module.exports = {
devServer: {
proxy: {
"/api": {
target: "<url>",
ws: true,
changeOrigin: true,
// 参考vue-cli官网配置示例,只需要添加下面这行参数。
router: useNiceProxy,
},
},
},
};webpack
如果你使用的是webpack,也只需要把你的webpack.config.js像上面修改一下即可。
提供的命令
list 列出所有代理
下面的命令都可以
npx nice-proxy listnpx nice-proxy ls
add 添加代理
npx nice-proxy add
执行该命令后,界面会继续让你输入要添加的代理的相关信息。
change 切换代理
npx nice-proxy changenpx nice-proxy use
执行该命令后,界面会列出当前所有代理让你选择。