souther 在 Windows 下让 Node 脚本稳定走 Clash 代理的几个坑,记录一下 中发帖

最近在写点 Node 小脚本,本机 Windows + Clash,代理这块反复折腾,把踩过的坑记下来给有需要的人。 

内置 fetch(undici)不认系统代理。HTTP_PROXY 设了也没用,得自己挂 ProxyAgent:

import { ProxyAgent } from 'undici'
const agent = new ProxyAgent('http://127.0.0.1:7897')
fetch(url, { dispatcher: agent })

axios 倒是认 HTTPS_PROXY 环境变量,两个库行为不一致,混用的时候容易懵。 


端口别照抄网上的教程。netstat -ano | findstr LISTENING 查一下自己 Clash 实际监听的端口,我本机是 7897,也有人是 7890,写错就是一堆 ETIMEDOUT。 


Pl...
 
 
Back to Top