CORS 代理服务

这是一个简单的 CORS 代理服务,帮助你解决跨域请求问题。

使用方法

基本用法:

https://your-domain.vercel.app/api/proxy?url=目标网址

示例:

https://your-domain.vercel.app/api/proxy?url=https://jsonplaceholder.typicode.com/posts/1

JavaScript 中使用:

// GET 请求
fetch('/api/proxy?url=https://api.example.com/data')
  .then(response => response.json())
  .then(data => console.log(data));

// POST 请求
fetch('/api/proxy?url=https://api.example.com/data', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ key: 'value' })
})
.then(response => response.json())
.then(data => console.log(data));

注意事项