Error: misconfigured csrf - Express JS 4

前端 未结 2 1448
庸人自扰
庸人自扰 2021-01-11 10:45

I am trying to enable the csrf module of Express 4 in an existing application.

I have added the following code:

var csrf = require(\'csurf\')
...

ap         


        
相关标签:
2条回答
  • 2021-01-11 11:32

    I have found the solution. The call to app.use(csrf()) must be set after app.use(cookieParser()) AND app.use(session({...}).

    0 讨论(0)
  • 2021-01-11 11:45

    If you're using Redis as a session store and the server isn't running, you will also get a misconfigured error.

    https://github.com/expressjs/csurf/issues/73

    0 讨论(0)
提交回复
热议问题