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

推荐订阅源

Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
NISL@THU
NISL@THU
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Engineering at Meta
Engineering at Meta
AWS News Blog
AWS News Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Privacy International News Feed
B
Blog
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
T
Tenable Blog
F
Fortinet All Blogs
G
GRAHAM CLULEY
V2EX - 技术
V2EX - 技术
C
Check Point Blog
Project Zero
Project Zero
P
Palo Alto Networks Blog
J
Java Code Geeks
W
WeLiveSecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Exploit Database - CXSecurity.com
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
S
SegmentFault 最新的问题
Last Week in AI
Last Week in AI
Forbes - Security
Forbes - Security
C
Cybersecurity and Infrastructure Security Agency CISA
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Recent Announcements
Recent Announcements
博客园 - Franky
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recorded Future
Recorded Future
The Last Watchdog
The Last Watchdog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

icodex | 前端技术博客 | 专注 React、TypeScript、AI 与性能优化 Blog

2026-07-18-前端与AI技术周报 TypeScript 7.0 正式发布 2026-07-12-前端与AI技术周报 2026-07-05-前端与AI技术周报 MCP 还是 CLI + Skill? 2026-06-28-前端与AI技术周报 2026-06-22-AI 产品周报 2026-06-22-前端技术周报 2026-06-14-AI 产品周报 2026-06-14-前端技术周报 2026-06-08-AI 产品周报 2026-06-07-前端技术周报 2026-05-31-AI 产品周报 2026-05-31-前端技术周报 2026-05-24-AI 产品周报 2026-05-24-前端技术周报 AI Review 在 electron 中使用 chrome-devtools-mcp pnpm 的 catalogs 功能 使用 SSE 与 Streamdown 实现 Markdown 流式渲染 JavaScript Intl 对象全面指南 POML 一种管理 Prompt 的工具 如何使用 Translator Web API eslint 支持多线程并发 Lint 下一代前端工具链对比 如何开发自己的一个 shadcn 组件 shadcn-ui实现原理 TypeScript全局类型定义的方式 IntersectionObserver API 用法 web图像格式对比(三) web图像格式对比(四) web图像格式对比(一) web图像格式对比(二)
混合内容请求限制
Oxygen · 2022-07-12 · via icodex | 前端技术博客 | 专注 React、TypeScript、AI 与性能优化 Blog

这两天又遇到一个图片问题,具体就是在 HTTPS 协议网页请求完的 HTTP 图片会被限制下载,这...,web 静态资源的问题还挺多坑。

Mixed Content 来自于 W3C 规范的定义 —— 混合内容 (以下简称规范),简单来说,当使用 HTTPS 请求的网页中包含其他通过 HTTP 请求的资源时,这些通过 HTTP 请求的内容就属于 Mixed Content。

W3C 的这篇规范不建议浏览器一律阻止所有混合内容的请求,视情况而定,将混合内容分为两种:

  • 可升级的混合内容请求,一般也被称为被动/显示混合内容
  • 无法升级的混合内容请求,一般也被称为主动型混合内容

被动型混合内容

被动混合内容主要是imgvideoaudio这些元素通过src属性指定的 URL 发起的请求,其本身既不受同源策略的限制,也不会受到这里混合内容的访问限制,并且浏览器还会自动帮助完成 HTTPS 访问的升级,然后在浏览器控制台给出一条如下提示内容,具体的可以移步这个网页观察细节 —— mixed content example (mixed-content.vercel.app)

image-20220719232438771

如果资源本身无法通过 HTTPS 访问,那么资源不会被加载并且报错。

W3C 也有个响应头来限制所有 HTTPS 站点内的 HTTP 请求 —— Content-Security-Policy: block-all-mixed-content,可以通过meta标签指定,不过这个请求头支持的浏览器比较少,目前这个属性值是被弃用了。

<meta
http-equiv="Content-Security-Policy"
content="block-all-mixed-content"
>

image-20220719233328676

主动型混合内容

主动性混合内容是指可以直接获取并修改页面数据的请求,也就是XMLHttpRequestfetch发起的 HTTP 请求,这些请求会被浏览器直接拦截,并不会发起跨域请求,然后在控制台提示报错信息。

image-20220720220835786

警告

主动型混合内容无法通过前端解决,只能后端统一升级 HTTPS,或者对于页面能够通过 HTTPS 请求的内容,手动修改请求 URL 的协议。