Skip to content

CSP, inline style nonce not set  #471

@webpack-bot

Description

@webpack-bot

Bug report

What is the current behavior?
On page load __webpack_nonce__ has a value, in injectStylesIntoStyleTag.js adding nonce to inline style is not done and it fails to add inline style at line 130 in very strange fashion. Although at line 110 __webpack_nonce__ has a value, after ternary operation nonce is undefined. Please check image from debuger https://snipboard.io/cqfYLC.jpg

If the current behavior is a bug, please provide the steps to reproduce.
In essence:

  • add CSP header with directive style-src self 'nonce-$NONCE'
  • assign $NONCE value to __webpack_nonce__ on page load
  • in app add inline styles in application
  • inline styles are ignored because of CSP

What is the expected behavior?
Inline styles have nonce added and pass CSP.

Other relevant information:
webpack version: 4.42.0
Node.js version: 14.3
Operating System: Mac OS X 10.14
Additional tools: Nx 9.3.0


This issue was moved from webpack/webpack#10962 by @evilebottnawi. Original issue was by @sasha-3ap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions