a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.14k stars 236 forks source link

feat: add nonce to reload script #784

Closed phenpessoa closed 3 weeks ago

phenpessoa commented 4 weeks ago

I realized that the reload script tag was hard coded as a constant string. This was causing errors when using CSP with the newly added WithNonce function.

I've made this PR so that the modifyResponse method parses the nonce from the request header (if present), and pass it along to insertScriptTagIntoBody to have it added to the script.

a-h commented 3 weeks ago

Thanks a lot!