create: 生产是 HTTP 访问,前端不能依赖安全上下文 API

MemRelay-Operation: memory-save:exp-http-secure-context-apis-20261111
MemRelay-Resource: eee5dad5-8523-4e3b-a76b-067d1cc7e16f
This commit is contained in:
2026-11-11 02:50:22 +08:00
parent 92198e66fe
commit f05f800329
@@ -0,0 +1,20 @@
---
title: 生产是 HTTP 访问,前端不能依赖安全上下文 API
type: experience
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/生产是-http-访问前端不能依赖安全上下文-api
stable_id: eee5dad5-8523-4e3b-a76b-067d1cc7e16f
scope: project
memory_type: experience
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
status: active
revision: 1
request_id: exp-http-secure-context-apis-20261111
created_at: '2026-11-10T18:50:16.449100+00:00'
updated_at: '2026-11-10T18:50:16.449100+00:00'
tags:
- frontend
- http
---
生产 Metrix 通过 http://188.5.127.115:18271 访问,不是安全上下文。crypto.randomUUID、navigator.clipboard、crypto.subtle 等只在 HTTPS 或 localhost 可用,本地开发不会暴露问题。前端要么不用这些 API(列表 key 用自增编号),要么像 utils/clipboard.ts 那样先判断 window.isSecureContext 再兜底。