Express CSRF token validation

后端 未结 3 1817
轻奢々
轻奢々 2020-12-17 00:44

I\'m having issues with CSRF tokens. When I submit a form, a new XSRF-TOKEN is being generated but I think I\'m generating two different tokens, I\'m kinda conf

3条回答
  •  遥遥无期
    2020-12-17 01:00

    the token in the cookie will be completely different than the one in the express session. you want to check for one or the other not both.

    i would disable the cookies entirely! as it worked for me.

    var csrfProtection = csurf({ cookie: false });

    the author mentions it here https://github.com/expressjs/csurf/issues/52

    next you want to the "X-CSRF-Token" to the header on ajax post found here: Express.js csrf token with jQuery Ajax

提交回复
热议问题