Open Kimotu opened 2 years ago
I also ran into this issue.
For example when a recommended Content Security Policy is used:
<meta http-equiv="Content-Security-Policy" content="default-src 'self'" />
no runtime style tags are allows to be inserted to the document (without a known hash/nonce).
This behaviour can be disabled by using
<meta name="htmx-config" content='{ "includeIndicatorStyles": false }' />
but it feels kind of awkward to add this everywhere.
Is there a reason why this style is added programmatically, instead of providing a separate htmx.css file that the users could include if needed?
Would you accept a PR here? I needed to add style-src 'unsafe-inline';
to my CSP to temporarily resolve this issue, but it loosens up the default security. I'd go with either of the proposed solutions here, though I'd prefer the CSS solution.
Please add config option
htmx.config.inlineStyleNonce:''
and extend functioninsertIndicatorStyles
to include:Tested it in a locale modified installation. Works.