私はログインページにアクセスしようとしているときにError: misconfigured csrf
を取得しています。私は、このモジュールを使用しています前に、私はセッションクッキーを始めているエラー:誤った設定のcsrf - Express.js
let router = require("express").Router();
let PostLoginResource = require("./../resources/PostLoginResource");
let RateLimit = require("express-rate-limit");
let csrf = require("csurf");
let csrfProtection = csrf({ cookie: true });
router.route("/login")
.get(csrfProtection, function(req, res) {
// Do some stuff
})
.post(loginLimiter, function(req, res) {
PostLoginResource(req, function(success, err) {
// Do some stuff
})
});
:私は、ルータにcsurfを実装するんだけど、私はただ、応答からstatusCodeに500
実装を取得していますapp.js:
// Parse the request body as JSON
app.use(bodyParser.json());
// Parse the URL encoded data
app.use(bodyParser.urlencoded({extended: true}));
// Set up session-cookie
app.use(session({
secret: "secret",
resave: false,
saveUninitialized: true,
cookie: {secure: true,
httpOnly: true,
maxAge: 1000 * 60 * 60 * 24
}
}));
まだ動作していません。誰が問題が何であるか知っていますか?
真であるので、我々はこれを必要とするが正しいそのパスです:./../resources/PostLoginResource? – Remario
はい、それ以外のエラーメッセージはエラーではありません:misconfigured csrf – Jesper
よく、内部エラーを意味する500を得ました。間違った文はそれを引き起こします。セッションオブジェクトはどこに必要ですか? – Remario