I am using multer and csurf package.
What is problem is that when i add enctype="multipart/form-data"
in form i get invalid csrd token.
app.js
// CSRF BEFORE ROUTES!!!
app.use(bodyParser.urlencoded({
extended: false
}))
app.use(cookieParser())
app.use(csrf());
app.use(function (req, res, next) {
res.locals.csrfToken = req.csrfToken();
next();
});
// Routes
app.use("/", webRoutes);
app.use("/cms", cmsRoutes);
and part of my users route which is inside my cmsRoutes
router.post("/edit", isAuthenticated, upload.single('avatar'), profile.user_edit_profile);
I found other people having the same problem. But cant find any solution to this.