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

推荐订阅源

H
Help Net Security
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
I
Intezer
Y
Y Combinator Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
Netflix TechBlog - Medium
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Hacker News: Ask HN
Hacker News: Ask HN
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
T
Tor Project blog
C
Cybersecurity and Infrastructure Security Agency CISA
云风的 BLOG
云风的 BLOG
博客园_首页
V2EX - 技术
V2EX - 技术
T
Threat Research - Cisco Blogs
腾讯CDC
宝玉的分享
宝玉的分享
博客园 - 叶小钗
罗磊的独立博客
S
Securelist
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
Scott Helme
Scott Helme
博客园 - 司徒正美
W
WeLiveSecurity
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Secure Thoughts
NISL@THU
NISL@THU
N
News and Events Feed by Topic
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
K
Kaspersky official blog
IT之家
IT之家

Serverless

大陆的 serverless 服务最近几年发展如何? 刷新下限?免费一个月也能说成每月免费 无服务架构方面,是 cf 的 workerd 还是 openfaas 纯容器堆栈版的方案好? - V2EX 国内能用真正按用量收费的 serverless 数据库 原来 serverless framework 只是一个开发者工具啊 请教大家访问数据库的接口用这东西怎么整? 求推荐学习基于 serverless, 最好是腾讯云的 cloudbase 开发的开源项目 几百万条更新频率很低的数据用什么低(零)成本的存储方便查询? - V2EX Cloudflare Workers 返回 request method、headers、body,用于开发自测请求信息 6 月 19 日 周日,华为 Serverless 等你来捧场 为什么 JavaScript 在云服务商的 serverless functions 服务中几乎都有支持? V2EX AI 事件驱动场景 Serverless 实践 Knativa 基于流量的灰度发布和自动弹性实践 Serverless Wordpress 建站三部曲 Serverless 如何在阿里巴巴实现规模化落地? 一图看懂:腾讯云 Serverless 2020 年的突破与收获 Serverless 架构到底要不要服务器? 创业公司用 Serverless,到底香不香? Serverless 是一种思想状态 - V2EX 都 2021 年了, Serverless 能取代微服务吗? 资源成本双优化!看 Serverless 颠覆编程教育的创新实践 Serverless 的价值 Serverless 在大规模数据处理的实践 5 大场景深度探讨何为 Serverless 架构模式? 人力节省 50%,研发效能提升 40%,阿里 Serverless 架构落地实践 一文搞懂函数计算及其工作原理 - V2EX Serverless 的初心、现状和未来 在线应用的 Serverless 实践 一文讲透 Serverless Kubernetes 容器服务 阿里 Midway 正式发布 Serverless v1.0 从单体迈向 Serverless 的避坑指南 为什么下一个十年的主战场在 Serverless? - V2EX 阿里云研究员叔同: Serverless 正当时! Serverless 架构下的服务优雅下线实践 Serverless Rap 一段有意思的 serverless Rap 视频 Serverless 安装 Laravel,flask,gin 等 web 框架,是否违背了它的使用场景? Serverless V2EX 客户端 国内有类似 Vercel 的平台吗? - V2EX 如何优雅地部署一个 Serverless Next.js 应用 - V2EX 如何将 Web 框架迁移到 Serverless - V2EX 现在各大云厂商都在推广的 Serverless 产品,和当初的 GAE/SAE/BAE,甚至是更早的“虚拟主机”,主要区别在哪? - V2EX 前端福音: Serverless 和 SSR 的天作之合 我又开始鼓捣 serverless 的无头浏览器了 - V2EX 基于 Serverless 与 Websocket 的聊天工具实现 Serverless 架构下, 3 分钟实现文本敏感词过滤 - V2EX Serverless Dashboard 设计解读与实战 现有的 Serverless 平台足够实时聊天的社区应用开发吗? - V2EX
Cloudflare Workers 反向代理+跨域
estk · 2022-06-25 · via Serverless

有时前端在调用一些第三方 API 时会遇到跨域问题,通过反代并在 headers 里配置即可跨域

async function handleRequest(request) {
  const urlObj = new URL(request.url)
  let url = urlObj.href.replace(urlObj.origin+'/', '').trim()
  if (0!==url.indexOf('https://') && 0===url.indexOf('https:')) {
    url = url.replace('https:/', 'https://')
  } else if (0!==url.indexOf('http://') && 0===url.indexOf('http:')) {
    url = url.replace('http:/', 'http://')
  }
  const response = await fetch(url, {
    headers: request.headers,
    body: request.body,
    method: request.method
  })
  let respHeaders = {}
  response.headers.forEach((value, key)=>respHeaders[key] = value)
  respHeaders['Access-Control-Allow-Origin'] = '*'
  return new Response( await response.blob() , {
    headers: respHeaders,
    status: response.status
  });
}
addEventListener('fetch', event => {
  return event.respondWith(handleRequest(event.request))
})

使用方法:

xxx.workers.dev/https://guge.com

可用于反代网页、json 甚至 image 等文件