venables / koa-helmet

Important security headers for koa
MIT License
639 stars 42 forks source link

ctx.state is undefined #32

Closed orion110217 closed 7 years ago

orion110217 commented 7 years ago

Hello, I've originally encountered a problem with JQuery and koa-helmet's CSP, but found a solution by generating nonce for JQuery. Now my problem is by following the helmet documentation on how to generate nonces, I can't seem to replicate it in KOA2, my app is throwing an error saying ctx.state is undefined.

orion110217 commented 7 years ago

Hi I solved this issue by adding this line of code ctx.req.nonce = ctx.state.nonce after ctx.req.secure = ctx.request.secure

now I can access my created object at req.nonce