NONCE error adding <script> src="..."</script> #5185

Closed
opened 2026-02-05 09:46:46 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @DoctorRetromaker on GitHub (Feb 16, 2025).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Trying to add «MathJax» lib in the "theme-hacking" way ...

  1. added <script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-mml-chtml.min.js"></script> to custom-head.blade.php
  2. <script> fails to load because a non correct "nonce" value

When same script is added in the settings|customization|Custom HTML Head Content and the 'nonce' value is added by the APP.

Is there any way to add the 'nonce' value inside blade template and add <script> tags inside any template?

I'm a absolutely newbie in blade templates ...

Exact BookStack Version

24.12.1

Log Content

No response

Hosting Environment

Linuxserver/BookStack Docker Container running in a Synology NAS like a charm ...

Originally created by @DoctorRetromaker on GitHub (Feb 16, 2025). ### Attempted Debugging - [x] I have read the debugging page ### Searched GitHub Issues - [x] I have searched GitHub for the issue. ### Describe the Scenario Trying to add «MathJax» lib in the "theme-hacking" way ... 1. added `<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-mml-chtml.min.js"></script>` to `custom-head.blade.php` 2. <script> fails to load because a non correct "nonce" value When same script is added in the `settings|customization|Custom HTML Head Content` and the 'nonce' value is added by the APP. Is there any way to add the 'nonce' value inside blade template and add <script> tags inside any template? I'm a absolutely newbie in blade templates ... ### Exact BookStack Version 24.12.1 ### Log Content _No response_ ### Hosting Environment Linuxserver/BookStack Docker Container running in a Synology NAS like a charm ...
OVERLORD added the 🐕 Support label 2026-02-05 09:46:46 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 17, 2025):

Hi @DoctorRetromaker,

You just need to add a nonce="{{ $cspNonce ?? '' }}" attribute within the script tag.
So:

<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-mml-chtml.min.js" nonce="{{ $cspNonce ?? '' }}"></script>
@ssddanbrown commented on GitHub (Feb 17, 2025): Hi @DoctorRetromaker, You just need to add a `nonce="{{ $cspNonce ?? '' }}"` attribute within the script tag. So: ```html <script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-mml-chtml.min.js" nonce="{{ $cspNonce ?? '' }}"></script> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5185