Warning: Array to string conversion in /disk/corsproxy/index.php on line 320
CORS Proxy · 跨域代理对接页
PHP 跨域代理 · 用法:?url=目标链接

✨ 这是什么

一个用 PHP 写的轻量跨域代理,解决前端直接请求第三方接口时的 CORS 跨域报错。 把目标 URL 塞进 ?url= 参数即可,代理会带上完整 CORS 响应头,浏览器即可正常读取。

类比:corsproxy.io/?url=https://api.example.com

🚀 快速体验

在下方输入任意 https:// 开头的接口地址,点“请求”试试:

响应将显示在这里…

📦 请求格式

GET 请求:

GET https://cors.muysky.cn/?url=https%3A%2F%2Fhttpbin.org%2Fget%3Fx%3D1%26y%3D2 HTTP/1.1

POST / PUT / PATCH / DELETE / HEAD / OPTIONS 同样支持,请求体与 Content-Type 会自动透传。

1 Access-Control-Allow-Origin: *

💻 前端对接示例

1. 原生 fetch

const PROXY = "https://cors.muysky.cn/?url=";

// GET
fetch(PROXY + encodeURIComponent("https://httpbin.org/get"))
  .then(r => { if(!r.ok) throw new Error(r.status); return r.json(); })
  .then(data => console.log(data))
  .catch(e => console.error("代理请求失败", e));

// POST 提交 JSON
fetch(PROXY + encodeURIComponent("https://httpbin.org/post"), {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "元宝", ts: Date.now() })
}).then(r => r.json()).then(console.log);

2. axios

import axios from "axios";

const proxyGet = url => axios.get("https://cors.muysky.cn/?url=" + encodeURIComponent(url));

proxyGet("https://httpbin.org/headers").then(res => {
  console.log(res.data);
  console.log("上游状态码:", res.status); // 真实上游状态码
});

3. 封装成 hook(React / Vue 通用)

function useProxy() {
  const request = async (url, init = {}) => {
    const res = await fetch("https://cors.muysky.cn/?url=" + encodeURIComponent(url), {
      ...init,
      headers: { "Content-Type": "application/json", ...(init.headers || {}) },
    });
    if (!res.ok) {
      const err = await res.json().catch(() => ({ error: res.statusText }));
      throw new Error(err.error || "request failed");
    }
    return res.json();
  };
  return { request };
}

⚠️ 生产环境必读

🔒 已内置的安全防护

• SSRF 防护:DNS 预解析 + 私有 IP 段拦截(10./172.16./192.168./127./169.254./100.64. 等)

• 协议白名单:仅 http/https,cURL 层 CURLOPT_PROTOCOLS 二次限制

• 保留域名拦截:.local .internal metadata. 等

• 请求体上限:默认 10MB,防内存耗尽

• 响应头净化:过滤 Connection、Transfer-Encoding、CSP 与上游自带的 Access-Control-*,避免冲突

• 相对 Location 补全:重定向地址自动拼成绝对 URL