From 8e484f29e92dc7931a40802bf987cdc9096bbf31 Mon Sep 17 00:00:00 2001 From: wood chen Date: Sun, 13 Jul 2025 04:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=89=E5=85=A8=E5=A4=B4?= =?UTF-8?q?=E9=83=A8=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AF=B7=E6=B1=82=E5=A4=B4=E5=A4=8D=E5=88=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E8=B7=B3=E8=BF=87=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=20hop-by-hop=20=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E5=92=8C=E5=AE=89=E5=85=A8=E5=A4=B4=E9=83=A8=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E5=AE=89=E5=85=A8=E6=80=A7=E5=92=8C=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/proxy.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/handler/proxy.go b/internal/handler/proxy.go index cd8b227..325426d 100644 --- a/internal/handler/proxy.go +++ b/internal/handler/proxy.go @@ -497,9 +497,17 @@ func copyHeader(dst, src http.Header) { } } - // 使用局部 map 快速查找,跳过 hop-by-hop 头部 + // 添加需要过滤的安全头部 + securityHeaders := map[string]bool{ + "Content-Security-Policy": true, + "Content-Security-Policy-Report-Only": true, + "X-Content-Security-Policy": true, + "X-WebKit-CSP": true, + } + + // 使用局部 map 快速查找,跳过 hop-by-hop 头部和安全头部 for k, vv := range src { - if !hopHeaders[k] { + if !hopHeaders[k] && !securityHeaders[k] { for _, v := range vv { dst.Add(k, v) }