version-fox / vfox-nodejs

Node.js plugin for vfox
https://vfox.lhan.me
Apache License 2.0
9 stars 3 forks source link

中科大的源发送请求会因缺少 User-Agent 请求头出现 403,导致无法使用 #15

Open muyiluop opened 1 week ago

muyiluop commented 1 week ago

版本地址:https://mirrors.ustc.edu.cn/node/index.json 直接curl请求没问题,使用nodejs插件请求会 403

muyiluop commented 1 week ago

实测是这个源需要 User-Agent 请求头,通过修改 .version-fox/plugin/nodejs/hooks/available.lua 文件,增加 User-Agent 请求头就行了。内容不限制,我给改成了版本号了,例如 vfox-nodejs/0.3.0

muyiluop commented 1 week ago

涉及到发送 http 请求的都有这个问题

muyiluop commented 1 week ago

pre_install.lua 脚本也需要修改下返回值,增加 User-Agent 请求头,不然无法下载 return { version = version, url = baseUrl .. filename, sha256 = checksum, headers = {["User-Agent"]="vfox-nodejs/0.3.0"} }