Skip to content

svelte/1: Add csp_nonce parameter#191

Open
xtian wants to merge 2 commits intowoutdp:masterfrom
xtian:csp-nonce
Open

svelte/1: Add csp_nonce parameter#191
xtian wants to merge 2 commits intowoutdp:masterfrom
xtian:csp-nonce

Conversation

@xtian
Copy link
Copy Markdown

@xtian xtian commented Oct 24, 2025

This PR updates LiveSvelte.svelte/1 to accept a Content-Security-Policy nonce to add to the generated <script> and <style> tags.

Fixes #102

@xtian xtian force-pushed the csp-nonce branch 2 times, most recently from 0cd13ef to b72fe17 Compare December 23, 2025 01:57
@gevera
Copy link
Copy Markdown
Collaborator

gevera commented Jan 10, 2026

@xtian Tests would be greatly appreciated

Comment thread lib/live_svelte.ex Outdated
<script>
<script {@csp_script_attrs}>
<%= raw(@ssr_render["head"]) %>
</script>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gevera Is it possible to remove this script tag? I'm not 100% on what @ssr_render contains, but @ssr_render["head"] is also rendered below in a div.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes. At the moment the priority is to backport LiveVue features to LiveSvelte (vite, igniter etc). Once that is finished, I am sure most of the issues opened will automatically be irrelevant. Might be this one as well. Will see.

@xtian
Copy link
Copy Markdown
Author

xtian commented Apr 10, 2026

@gevera I updated with tests

Comment thread package.json
"import": "./assets/js/live_svelte/index.ts",
"types": "./assets/js/live_svelte/types.d.ts"
"types": "./assets/js/live_svelte/types.d.ts",
"import": "./assets/js/live_svelte/index.ts"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed this change to fix type errors in my project

@woutdp woutdp force-pushed the master branch 5 times, most recently from 3c92d4e to ec88a7b Compare April 17, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support CSP nonce in script and style tags

3 participants