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

推荐订阅源

小众软件
小众软件
N
News and Events Feed by Topic
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Engineering at Meta
Engineering at Meta
Google Online Security Blog
Google Online Security Blog
宝玉的分享
宝玉的分享
AI
AI
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
H
Hacker News: Front Page
F
Fortinet All Blogs
博客园_首页
S
Secure Thoughts
N
News and Events Feed by Topic
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Spread Privacy
Spread Privacy
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Know Your Adversary
Know Your Adversary
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
PCI Perspectives
PCI Perspectives
L
LangChain Blog
雷峰网
雷峰网
Security Archives - TechRepublic
Security Archives - TechRepublic
V2EX - 技术
V2EX - 技术

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 等文件