Sinatra inspired web development framework for node.js -- insanely fast, flexible, and simple
The app.router object, which was removed in Express 4, has made a comeback in Express 5. In the new version, this object is a just a reference to the base Express router, unlike in Express 3, where an app had to explicitly load it.
@nfantone did you get a resolution for your comment here https://github.com/expressjs/express/pull/4321#issuecomment-1003836216 ?
I'm confused. Once pillarjs/router#102 is merged, a new (beta?) version of router would need to be cut and express would need to be updated again.
Also changes in 1574925 were already part of #4752, which was put on hold and marked as "Draft" until the above takes place, but I see no mention of this.
info
, debug
, etc functions to the request object, that logs whatever you give it prefixed with a request ID
Hi I am working on an Express App with TypeScript
I am trying to configure CSRF Tokens with the CSURF Library. I followed the documentation accordingly and I when I ran my app, there was no problem. However, upon trying to make a POST request, I get a 403 error saying ForbiddenError : invalid csrf token
The following is the code in my main express app called app.ts
import express, { request, Request, Response } from 'express'
import 'dotenv/config'
import passport from 'passport';
import session from 'express-session';
import clientController from './client/client';
import cors from 'cors';
import csurf from 'csurf';
import cookieParser from 'cookie-parser';
import bodyParser from 'body-parser';
const app = express();
app.use(cookieParser())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.json())
app.use(cors({
credentials: true,
origin: ['http://localhost:3000']
}));
const csrfMiddleware = csurf({ cookie: true })
const port = process.env.PORT
const sessionSecret = process.env.SESSION_SECRET
app.use(session({
secret: sessionSecret!.toString(),
resave: true,
saveUninitialized: false,
cookie: {
httpOnly: true
}
}))
app.use(csrfMiddleware)
app.use(passport.initialize());
app.use(passport.session());
passport.serializeUser((user: Object, done) => {
console.log(user)
done(null, user)
})
passport.deserializeUser((user: Object, done) => {
done(null, user);
})
//Authentication route
const authRoute = authController
app.use('/auth', authRoute);
I hope someone can assist me with this because I've spent a day or so trying to troubleshoot as to why I can't get csrf working