Skip to content

Getting undefined function conn/0 when inserting the nonce inside script tag. #6

@AbhiKafle123

Description

@AbhiKafle123

The documentation mentions

If nonces are requested for any directives, they will be available in the assigns map of the conn as _nonce — e.g., conn.assigns[:style_src_nonce] — and the nonce will be inserted into the CSP header.

Creating nonce-

plug PlugContentSecurityPolicy,
      nonces_for: [:script_src],
      directives: %{script_src : ~w('self')}
      

assigning nonce-

<<script nonce= "<%conn.assigns[:script_src_nonce]%>" >
      //some inline scripts
 </script>

I was able to generate nonce for script tag in the csp header but when inserting it into inline JS, I am getting 'Compile error - undefined function conn/0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions