Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Add support for nonce #160

Merged
merged 7 commits into from
Jun 7, 2022

Conversation

lipsumar
Copy link
Contributor

This PR adds a way to specify an nonce attribute for the <script> tag injected by sendLayoutHTTPResponse.

This script tag being crucial to single-spa, it's currently impossible to use it with a strict CSP. We're currently using it in production, but we need to search the whole output and replace <script> with <script nonce="...">, not an optimal solution.

Another approach to solve this would be to prevent the browser from evaluating this script tag (by setting a type different than a javascript mime type), and then manually read from it in single-spa's client script.

@MarcusResell
Copy link
Contributor

Nice, was about to do this one myself as we're also in need of it. Currently we keep that script snippet empty and "live" with the csp violation logged in the browser. Do you have time to add tests for it?

GeeWizWow and others added 3 commits June 7, 2022 16:16
Copy link
Member

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

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

Thanks for this, it would be nice to have a test for this so I'll push to your branch with a test, then merge.

@joeldenning joeldenning merged commit 7507dd5 into single-spa:main Jun 7, 2022
@joeldenning
Copy link
Member

@joeldenning
Copy link
Member

Documented in single-spa/single-spa.js.org#553

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.

6 participants