Skip to content

remix/middleware/csp · Function

View Source

getCspNonce

Summary

Gets the CSP nonce for authored script and style tags or custom rendering. Internal frame requests use the enclosing document's nonce. Reading it does not generate one.

Signature

function getCspNonce(context: RequestContext<AnyParams, ContextEntries>): string | undefined

Example

<script src="/app.js" nonce={getCspNonce(context)} />

Parameters

context

Current request context.

Returns

The nonce, or undefined when no nonce has been established.