getCSPNonce

Returns the nonce that ColdFusion adds to the Content-Security-Policy header for the current request. Put it on inline script tags so the browser allows them to run.

getCSPNonce([returnAsString]) → returns string

This function requires Adobe ColdFusion 2025 and up.  Not supported on Lucee, etc.

Argument Reference

returnAsString boolean
Default: false

true to return the value in nonce="..." attribute form, ready to place inside a script tag.
Values:
  • true
  • false

Links more information about getCSPNonce

Examples
Sample code invoking the getCSPNonce function

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub