From 7b955dfa445caf1b4957781fa45fe73cc7961600 Mon Sep 17 00:00:00 2001 From: Zhi Date: Thu, 11 Jun 2026 21:47:06 +0800 Subject: [PATCH] fix: append nonce alongside unsafe-inline instead of replacing it --- packages/fresh/src/middlewares/csp.ts | 18 +++++-- packages/fresh/src/middlewares/csp_test.tsx | 58 ++++++++++++++++++--- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/packages/fresh/src/middlewares/csp.ts b/packages/fresh/src/middlewares/csp.ts index 0f0b6f558c4..cb27ce45c6d 100644 --- a/packages/fresh/src/middlewares/csp.ts +++ b/packages/fresh/src/middlewares/csp.ts @@ -12,11 +12,16 @@ export interface CSPOptions { csp?: string[]; /** - * If true, replaces 'unsafe-inline' with a nonce-based policy for - * script-src and style-src directives. Fresh automatically injects + * If true, appends a nonce to 'unsafe-inline' entries in the policy + * for script-src and style-src directives. Fresh automatically injects * nonce attributes on inline `