diff --git a/.changeset/angry-geckos-dream.md b/.changeset/angry-geckos-dream.md
new file mode 100644
index 000000000000..a111db1ff8b9
--- /dev/null
+++ b/.changeset/angry-geckos-dream.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+fix: add CSP hashes/nonces to inline styles when using `bundleStrategy: 'inline'`
diff --git a/packages/kit/src/runtime/server/page/csp.js b/packages/kit/src/runtime/server/page/csp.js
index 7596385ba8a5..1376235b45de 100644
--- a/packages/kit/src/runtime/server/page/csp.js
+++ b/packages/kit/src/runtime/server/page/csp.js
@@ -186,10 +186,6 @@ class BaseProvider {
this.#style_src.push(source);
}
- if (this.#style_src_needs_csp) {
- this.#style_src.push(source);
- }
-
if (this.#style_src_attr_needs_csp) {
this.#style_src_attr.push(source);
}
diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js
index 550d266fc964..d8fbe32a7ed8 100644
--- a/packages/kit/src/runtime/server/page/render.js
+++ b/packages/kit/src/runtime/server/page/render.js
@@ -228,19 +228,18 @@ export async function render_response({
return `${assets}/${path}`;
};
- if (client.inline?.style) {
- head += `\n\t`;
- }
-
- if (inline_styles.size > 0) {
- const content = Array.from(inline_styles.values()).join('\n');
+ // inline styles can come from `bundleStrategy: 'inline'` or `inlineStyleThreshold`
+ const style = client.inline
+ ? client.inline?.style
+ : Array.from(inline_styles.values()).join('\n');
+ if (style) {
const attributes = __SVELTEKIT_DEV__ ? [' data-sveltekit'] : [];
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
- csp.add_style(content);
+ csp.add_style(style);
- head += `\n\t`;
+ head += `\n\t`;
}
for (const dep of stylesheets) {