Skip to content

Proxy

一、Whistle

Whistle

安装证书

Chrome 插件

1、下载

bash
npm i -g whistle

2、启动

bash
w2 start
# 重启
w2 restart
# 暂停
w2 stop

3、下载证书

bash
# 这样下载后,不需要手动安装
w2 ca

注:先启动,才能下载证书。

image-20250911002648293

4、使用

参考

1)打开

http://127.0.0.1:8899/

2)配置插件

服务写 127.0.0.1,端口写 w2 start 启动的端口号。

image-20250911002950079

image-20250911003656781

3)系统设置

image-20250911003259922

4)配置代理规则

例:

打开 https://github.com/ 时,重定向到 <www.baidu.com>

image-20250911004029227

配置规则

5)Vite 热更新保留配置

1️⃣ vite.config.mts 中配置

js
  server: {
    // 代理 ws
    hmr: {
      host: 'localhost',
      protocol: 'ws',
      port: 5173,
    }    
  },

2️⃣ 修改 Whistle 规则配置

注:注意端口号对应关系

https://test.xxx.com/ http://localhost:8087/


# 透传 Vite HMR 的 WebSocket 请求
wss://localhost:8087 ws://localhost:5173
ws://localhost:8087 ws://localhost:5173

基于 MIT 许可发布