
使用Cloudflare Worker做API转发
今天行长@justyy说Cloudflare 现在的worker免费,每天可以10万次调用
这个worker的应用场景很多,比如load balancing, api转发,在线代理等等
比较有兴趣的是api转发。api转发应用场景是,比如你想访问一个国外的api,但是国内的墙很高,翻不过去,你就可以用api转发了
你把请求发向没有墙的worker,这个worker会替你把请求转发到有墙的api去,等收到api返回的数据后,再返回给你。这样你就可以在没墙的情况下访问国外api
转发API的代码:
1 | addEventListener('fetch', event => { |
目前这个工具运行良好,就是每天的10w请求有点不太够用
- Thanks for your appreciation. / 感谢您的赞赏
List of appreciation
Because of your support, I realize the value of writing articles. / 由于您的支持,我才能够实现写作的价值。
This piece of writing is an original article, utilizing theCC BY-NC-SA 4.0Agreement. For complete reproduction, please acknowledge the source as Courtesy ofERICET
Comment ()