你的后端 → Vercel中转(美国IP) → Roboflow API 绕过 Cloudflare 对中国 IP 的封锁,免费、永久有效。
-
安装 Vercel CLI:
npm install -g vercel
-
进入 roboflow-proxy 文件夹:
cd roboflow-proxy -
部署:
vercel --yes
-
首次会要求登录(用 GitHub 账号即可),然后自动部署。 部署完成后会显示类似:
https://roboflow-proxy-xxxx.vercel.app记下这个 URL。
-
部署到生产环境(获得稳定链接):
vercel --prod
- 把 roboflow-proxy 文件夹推到一个 GitHub 仓库
- 打开 https://vercel.com ,用 GitHub 登录
- 点 "New Project" → 选那个仓库 → Deploy
- 部署完成后拿到 URL
部署成功后,在你电脑 PowerShell 里测试(把 xxx 换成你的 Vercel 域名):
curl.exe "https://roboflow-proxy-xxx.vercel.app/api/detect/litter-detection-pbz2j/6?api_key=rf_1m1qOpiQOXevcsuhLHhi7FJm1Uv1&image=https://media.roboflow.com/dog.jpeg"如果返回 JSON 检测结果(而不是 Cloudflare 拦截页),说明代理正常工作。
如果返回的是 Roboflow 的 JSON 错误(比如 invalid api key),那是 key 或模型的问题,跟代理无关。
在你的后端项目里找到调用 Roboflow 的代码。
通常在 backend/app/ 目录下某个文件里,搜索 detect.roboflow.com,
把:
https://detect.roboflow.com/改成:
https://roboflow-proxy-xxx.vercel.app/api/detect/只是换了域名前缀,后面的模型路径、api_key 参数完全不变。
然后重启后端:
systemctl restart cityeye-backend手机采集页点"开始采集",后端的 Roboflow 请求会走 Vercel 中转,不再被 Cloudflare 拦截。