Skip to content

Commit e6374c1

Browse files
authored
[fix] dont add nonce attribute to <link> elements (#8369)
fixes #8200
1 parent 91a5385 commit e6374c1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.changeset/wet-feet-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] don't add nonce attribute to `<link>` elements

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,17 @@ export async function render_response({
211211
const path = prefixed(dep);
212212

213213
if (resolve_opts.preload({ type: 'css', path })) {
214-
const attributes = [];
215-
216-
if (csp.style_needs_nonce) {
217-
attributes.push(`nonce="${csp.nonce}"`);
218-
}
214+
const attributes = ['rel="stylesheet"'];
219215

220216
if (inline_styles.has(dep)) {
221217
// don't load stylesheets that are already inlined
222218
// include them in disabled state so that Vite can detect them and doesn't try to add them
223219
attributes.push('disabled', 'media="(max-width: 0)"');
224220
} else {
225-
const preload_atts = ['rel="preload"', 'as="style"'].concat(attributes);
221+
const preload_atts = ['rel="preload"', 'as="style"'];
226222
link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(';')}; nopush`);
227223
}
228224

229-
attributes.unshift('rel="stylesheet"');
230225
head += `\n\t\t<link href="${path}" ${attributes.join(' ')}>`;
231226
}
232227
}

0 commit comments

Comments
 (0)