Comments (3)
你可以认为这个插件,只是做了一层 URL 的转发。
直接下载插件就可以使用,规则配置,可以参考下面。
主要为了解决想把 URL 里面,某些值替换掉。
{
"proxy": [
[
"https://www.taobao.com", // 想要被转发的 URL
"https://www.tmall.com" // 想要被转发到的 URL
],
]
}
这样的话,如果你访问,https://www.taobao.com?params=12345 的话,插件会自动帮你转到 https://www.tmall.com?params=12345 。
只要经过浏览器请求的地址,都会过一遍规则。
不过一般我们不会做上面这种规则。大部分都是想代理到本地。比如阿里这边一般经常使用 g.alicdn.com
这个域名的 CDN 文件。
比如想要把这段代码转发到本地:https://g.alicdn.com/mtb/lib-windvane/2.0.3/windvane.js
-
只是想匹配路径。
{ "proxy": [ // 将请求中,匹配到部分路径的 URL ,匹配到本地。 [ "https://g.alicdn.com/mtb/lib-windvane/2.0.3/", "http://127.0.0.1:3000/" // 推荐写 127.0.0.1 而不是 localhost 。因为 127.0.0.1 被允许 https 下访问,而不会出现不安全脚本警告。 ], ] }
-
想精确匹配 JS ,因为很多时候,webpack 打出的 CSS 我们在调试模式的时候,会直接通过 JS 进行加载。
{ "proxy": [ // 将请求中,匹配到部分路径的 URL ,匹配到本地。 [ "https://g.alicdn.com/mtb/lib-windvane/(.*)/(.*).js", "http://127.0.0.1:3000/$2?t=123" // $2 就表示是第二个匹配到的字符。这里的 $1 是版本号,一般我们不需要关心它。 ], ] }
from xswitch.
到那里下载插件呢?大陆被屏蔽了上不了谷歌阿。还是不知道怎么使用。
from xswitch.
可以直接 clone 项目,然后在 Chrome Extension 里,开发者模式载入 build 文件夹就好。使用方法可以看 Readme 的优酷视频。
from xswitch.
Related Issues (20)
- wss、ws 请求无法转发 HOT 1
- 快捷键跟语雀的冲突,后续解决
- 希望左侧已添加的rule能修改名字? HOT 3
- 开启后转发错误 (failed) net::ERR_FAILED HOT 1
- CPU占用高 HOT 4
- release issue HOT 1
- 测试了下baidu.com跨域失败 请问是我配置不对吗?
- 可以更改host指向吗 HOT 1
- 按照视频做,跨域失败
- 把https 转发到 本地使用 127.0.0.1 失效? HOT 2
- feature: 如果能处理接口返回的数据就更好了
- Chrome memory cache 和 disk cache 失效 HOT 1
- 能发一份到微软 Edge 应用商店么?
- 能限定规则在指定域名下生效么
- 能够支持配置同步吗?
- 请问能修改get请求参数吗
- 转发之后cookie请求就不再带有该参数了
- 请问一下如何把线上的 main.[hash].js 转发到 本地的 main.[hash].js,本地和线上hash不一致?
- authorization header 不携带 HOT 4
- 跨域至本地的端口被其他程序占用,也会造成跨域失败
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xswitch.