Closed riovir closed 6 years ago
Couldn't that be solved by adding the sha value of the component in the CSP style-url list?
When I imported my component build with StencilJS in my Ionic project, I saw the CSP warning in the Chrome debugger, telling my to add unsafe-inline
or to add the regarding 'sha256-xxxxx'
value to the style-src
of my CSP. I did added the sha value, restarted my project and the issue was solved.
Indeed adding the sha256
value provides a way to approach the problem. Unfortunately this angle is less than ideal in some scenarios:
A special entry or two per Stencil component collection would be acceptable though as a workaround if CSS files are not an option.
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.
Thank you for using Stencil!
Stencil version:
I'm submitting a:
Current behavior: A components currently rely on inline
<style>
tags. WhenContent-Security-Policy
headers forbidunsafe-inline
the styling breaks.Expected behavior: Any solution that allows strict CSP policies and well styled Stencil components to coexist.
One approach could be for Stencil to generate CSS files at compilation time to which
<style>
tags would refer.Steps to reproduce:
styleUrl
specifying some stylesContent-Security-Policy = "style-src 'self' ;"
Related code:
The following snippet spins up a proxy from port
5000
to3333
banning inline style tags. (Assumingexpress
andexpress-http-proxy
are installed.)