Skip to content

Commit 068a914

Browse files
committed
fix: add nonce in stream data part
1 parent e4c1ffa commit 068a914

File tree

1 file changed

+6
-2
lines changed
  • packages/kit/src/runtime/server/page

1 file changed

+6
-2
lines changed

packages/kit/src/runtime/server/page/render.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export async function render_response({
265265
event,
266266
options,
267267
branch.map((b) => b.server_data),
268+
csp,
268269
global
269270
);
270271

@@ -522,10 +523,11 @@ export async function render_response({
522523
* @param {import('@sveltejs/kit').RequestEvent} event
523524
* @param {import('types').SSROptions} options
524525
* @param {Array<import('types').ServerDataNode | null>} nodes
526+
* @param {import('./csp.js').Csp} csp
525527
* @param {string} global
526528
* @returns {{ data: string, chunks: AsyncIterable<string> | null }}
527529
*/
528-
function get_data(event, options, nodes, global) {
530+
function get_data(event, options, nodes, csp, global) {
529531
let promise_id = 1;
530532
let count = 0;
531533

@@ -564,7 +566,9 @@ function get_data(event, options, nodes, global) {
564566
str = devalue.uneval({ id, data, error }, replacer);
565567
}
566568

567-
push(`<script>${global}.resolve(${str})</script>\n`);
569+
push(
570+
`<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${global}.resolve(${str})</script>\n`
571+
);
568572
if (count === 0) done();
569573
}
570574
);

0 commit comments

Comments
 (0)