惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Proofpoint News Feed
D
Docker
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
IT之家
IT之家
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
B
Blog
D
DataBreaches.Net

WishMeLz - Linux

目标域名在线测试 - WishMeLz NodeBB 搭建安装笔记 v4.x - WishMeLz puppeteer在Linux端 依赖库确实 libdrm.so.2,libnss3.so Linux 工具箱整理 - WishMeLz docker 镜像加速 - WishMeLz Certimate 使用教程 - WishMeLz ip自签名ssl证书 - WishMeLz PM2搭配nvm使用不同版本Node启动项目 - WishMeLz shell脚本备份数据库 - WishMeLz
cors-anywhere Nodejs实现静态资源代理,使用ESA加速访问 - W...
WishMeLz · 2026-06-01 · via WishMeLz - Linux

解决前端访问静态资源CORS跨域的问题 https://github.com/WishMelz/cors-anywhere 【添加只允许代理静态资源条件判断】;原仓库:https://github.com/Rob--W/cors-anywhere

此仓库代码仅仅帮忙解决前端下载CORS资源问题,请勿非法使用!!!

举个使用场景:html2canvas、Fabric.js、Three.js 等前端库在把外部图片绘制到 <canvas> 时,若目标服务器未返回 Access-Control-Allow-Origin:*,浏览器会抛出 CORS 错误。

1、快速使用(公共实例)

https://cors.xzxo.cn/<资源URL>
https://cors.xzxo.cn/https://i0.kym-cdn.com/photos/images/original/000/798/744/f10.gif
https://cors.xzxo.cn/https://raw.githubusercontent.com/WishMelz/file/refs/heads/master/image/93120923874f9477d30035b76d9978e0.jpg

GitHub 文件测试
https://raw.githubusercontent.com/WishMelz/file/refs/heads/master/image/93120923874f9477d30035b76d9978e0.jpg

2、搭建

服务启动

git clone https://github.com/WishMelz/cors-anywhere.git
cd cors-anywhere
npm i 
pm2 start server.js  // 默认端口是8080

nginx配置

location ^~ / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Real-Port $remote_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    proxy_connect_timeout 60s;
    proxy_send_timeout 600s;
    proxy_read_timeout 600s;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}

ESA配置

2025-08-06T16:48:27.png

来一把全球PING

2025-08-06T16:56:46.png

合规声明

本项目仅供合法解决前端 CORS 下载问题使用。禁止用于绕过版权、非法抓取、接口攻击等行为。使用者须遵守目标站点 robots.txt 及当地法律法规,违者后果自负。


最后编辑时间为: August 7th , 2025 at 12:57 am
本文由 Wish 创作,采用 知识共享署名 4.0 国际许可协议进行许可
可自由转载、引用,但需署名作者且注明文章出处

标签 : 无标签