Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:48:48+00:00 2026-06-01T14:48:48+00:00

Have successfully gotten the csrf middleware working in express as per previous SO questions.

  • 0

Have successfully gotten the csrf middleware working in express as per previous SO questions. It’s generating the tokens fine however it is denying ALL form submissions.

The only possible conflict I can see is that I am using redis as a session store with connect-redis and plugging socket.io into the session, but I’ve commented out the socket bits and it’s still not playing nice.

This is the order I’m calling my middleware is somethign possibly screwy here?

(CoffeeScript)

app.configure ->
    app.set 'views', __dirname + '/views'
    app.set 'view engine', 'jade'
    app.use express.bodyParser()
    app.use express.methodOverride()
    app.use express.cookieParser()
    app.use express.session
        secret: "itsasecret"
        store: sessionStore
    app.use express.csrf()
    app.dynamicHelpers
        token: (req, res) ->
        req.session._csrf
    app.use app.router
    app.use express.static(__dirname + '/public')

This is the route that responds to the posted data.

(This is not development code, just me learning node I am well aware this would be a monstrosity if I put it online)

app.post '/admin/logintry', (req, res) ->
    if req.body.username is 'Tim' and req.body.password is 'TempPassword'
        req.session.adminIn = true
        res.redirect '/admin/home'
    else
        res.redirect '/admin/login?failed=true'

Here is the HTML that is reaching the browser on the form page:

<input type="hidden" token="5ODFxml1QAhQvOmq1QE6Qd7n">

And the response received from “/admin/logintry”:

Forbidden

New to Node, Express and SO, only recently properly learnt javascript, unsure where to even start looking for issues. Any help, even just on where to start digging greatly appreciated.

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:48:50+00:00Added an answer on June 1, 2026 at 2:48 pm

    If you look at the Connect – csrf documentation, the input tag for the token should look like this:

    <input type="hidden" name="_csrf" value="{token}" />
    

    So with your example token:

    <input type="hidden" name="_csrf" value="5ODFxml1QAhQvOmq1QE6Qd7n" />
    

    Currently Connect (Express uses Connect under the hood) is trying to find the field with the name “_csrf” but can’t find it, because it doesn’t exist in your form. Therefore, it forbids the access.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise this question has been asked before however the previous answers have gotten
I have successfully set up FILESTREAM on my SQL 2008 server; however I've noticed
I have successfully gotten my low-level mouse hook code to work, but there are
I have successfully gotten Dreamweaver to accept my DLL and call it's methods. The
I have a multistop gradient created with colorzilla that I have successfully gotten to
I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008)
I have successfully managed to get System.Speech.Synthesis to read English text in arbitrary voices
I have successfully implemented interop beftween Win32 application and managed .Net dll as described
I have successfully upgraded an MFC application which was compiled with an old version
I have successfully used the Excel and Word addin templates in Visual studio 2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.