-
Notifications
You must be signed in to change notification settings - Fork 766
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
bug: Nonce not being added to styles #5506
Comments
Hey @AliKdhim87! Thanks for the issue! Do you know if this is a problem without Next.js in the equation? The reproduction feels a bit complicated at the moment, so it would be great if we could strip out some aspects to help isolate the issue! |
Hey, @tanner-reits! I'm able to reproduce this with Angular on a fresh I've followed the steps in the documentation, but Repo: https://github.com/Yudi/csp-nonce-ionic-error/ To reproduce, I set the following: // package.json
"@ionic/angular": "^8.2.0",
"@ionic/core": "^8.2.0", <!-- index.html -->
<meta
http-equiv="Content-Security-Policy"
content="script-src 'self' 'nonce-randomNonceGoesHere'; style-src 'self' 'nonce-randomNonceGoesHere'"
/> // main.ts
import { setNonce } from '@ionic/core/loader';
...
const nonce = 'randomNonceGoesHere';
setNonce(nonce);
bootstrapApplication(AppComponent, {
providers: [
{ provide: CSP_NONCE, useValue: nonce },
...
|
Prerequisites
Stencil Version
4.12.6
Current Behavior
I encountered an issue where the nonce attribute is not being added to the <style> elements in the rendered HTML output of a web application built using Next.js 14.1.3 and Stencil Core version 4.12.6. Despite attempting to use the
setNonce
function provided by StencilJS as described in the documentation, the nonce attribute is not reflected in the final rendered HTML.Error Message (Observed in Browser):
Expected Behavior
The nonce attribute should be added to all
<style>
elements in the rendered HTML output, ensuring compliance with Content Security Policy (CSP) requirements.System Info
Steps to Reproduce
setNonce
function to dynamically set the nonce attribute on<style>
elements.nonce
attribute exists in the HTML document.Code Reproduction URL
https://github.com/AliKdhim87/configure-csp-nextjs-with-stenciljs
Additional Information
Screenshots:
The text was updated successfully, but these errors were encountered: