From 073ad8798ca7ddef9656eccde5852e5da5426a71 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 21 Nov 2025 20:11:24 +0800 Subject: [PATCH] =?UTF-8?q?1446=20fix:=20=E4=BF=AE=E5=A4=8DAPI=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=8A=A0=E5=AF=86=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=20header=20=E6=A0=87=E8=AF=86=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/filter/ApiEncryptResponseWrapper.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptResponseWrapper.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptResponseWrapper.java index 194e525c28..a7b38f7dba 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptResponseWrapper.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptResponseWrapper.java @@ -42,16 +42,15 @@ public class ApiEncryptResponseWrapper extends HttpServletResponseWrapper { this.flushBuffer(); byte[] body = byteArrayOutputStream.toByteArray(); - // 2. 加密 body - String encryptedBody = symmetricEncryptor != null ? symmetricEncryptor.encryptBase64(body) - : asymmetricEncryptor.encryptBase64(body, KeyType.PublicKey); - - // 3. 添加加密 header 标识(设置header要放在response的write之前) + // 2. 添加加密 header 标识 this.addHeader(properties.getHeader(), "true"); // 特殊:特殊:https://juejin.cn/post/6867327674675625992 this.addHeader("Access-Control-Expose-Headers", properties.getHeader()); - // 4. 输出加密后的 body + // 3.1 加密 body + String encryptedBody = symmetricEncryptor != null ? symmetricEncryptor.encryptBase64(body) + : asymmetricEncryptor.encryptBase64(body, KeyType.PublicKey); + // 3.2 输出加密后的 body:(设置 header 要放在 response 的 write 之前) response.getWriter().write(encryptedBody); }