错误:配置错误csrf - Express JS 4 [英] Error: misconfigured csrf - Express JS 4
本文介绍了错误:配置错误csrf - Express JS 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在现有应用程序中启用Express 4的 csrf 模块。
I am trying to enable the csrf module of Express 4 in an existing application.
我添加了以下代码:
var csrf = require('csurf')
...
app.use(csrf());
我已经开始了我的申请,我得到:
I have started my application and I get:
Error: misconfigured csrf
和堆栈跟踪。没有其他的。
and a stack trace. Nothing else.
我已经检查了文档,但不清楚。有人可以帮忙吗?使用此模块所需的最低配置是多少?
I have checked the documentation, but it is unclear. Can someone help? What is the minimum configuration required to use this module?
推荐答案
我找到了解决方案。必须在 app.use(cookieParser())
之后设置对 app.use(csrf())
的调用 app.use(session({...})
。
I have found the solution. The call to app.use(csrf())
must be set after app.use(cookieParser())
AND app.use(session({...})
.
这篇关于错误:配置错误csrf - Express JS 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文