NProxy安装和使用详解

xiaoxiao2021-02-27  236

1.首先要先安装node.js 可在cmd下使用node --version查看版本 2.使用npm安装nproxy npm install -g nproxy 3.建立replace_rule.js 例如在盘 nproxy文件夹下新建replace_rule.js 里面的代码如下所示: module.exports = [ // 1. replace single file with local one { pattern: '/views/default/skin/default/css/publish.css', // Match url you wanna replace --------- 线上访问路径 responder: "D:/publish.css" --------- / 本地映射文件路径 }, // 2. replace single file with web file { pattern: 'homepage.js', // Match url you wanna replace responder: "http://www.anotherwebsite.com/assets/js/homepage2.js" }, // 3. replace combo file with src with absolute file path { pattern: 'group/homepageTileFramework.*.js', responder: [ '/home/goddyzhao/workspace/webapp/ui/homepage/js/a.js', '/home/goddyzhao/workspace/webapp/ui/homepage/js/b.js', '/home/goddyzhao/workspace/webapp/ui/homepage/js/c.js' ] } ]; 4。启动nproxy 并设置端口为8181 nproxy -l D:/nproxy/replace_rule.js -p 8181 -------------注意你js文件放的路径 5.设置浏览器代理 Google浏览器: 火狐浏览器也是一样操作的 测试效果:在浏览器上输入你要重定向的地址 http://test.justdiy.cn/index.php/jd_weixinshu/design/source/7T62/control/preview/id/3429/section/cover 开启浏览器代理,这时上面的地址无法访问 然后进入cmd中输入 nproxy -l D:/nproxy/replace_rule.js -p 8181; 会提示 然后强制刷新页面(ctrl+f5)会出现如下提示说明正常 这下就可以修改本地css文件对线上有用了
转载请注明原文地址: https://www.6miu.com/read-15429.html

最新回复(0)