#Type string is not assignable to Request<ParamsDictionary> express-session

14 messages · Page 1 of 1 (latest)

latent tiger
#

I have installed express-session and @types/express-session. This is my config file

export default session({
    name: "sid", 
    genid: uuid(),
    secret: process.env.COOKIES_SECRET, 
    cookie: {
        domain: "localhost:3000",
        httpOnly: true,
        maxAge: 30 * 24 * 60 * 60 * 1000, 
        path: "/", 
        sameSite: true,
        secure: true
    }
})
fresh pendant
#

read the doc for express-session

#

calling the session only creates the middleware with some options

#

needs to be a function, can't return the uuid directly

#

also, for the secret, TS doesn't know what type process.env.COOKIES_SECRET is

#

it might be undefined

#

there is a chance that env variable isn't set or doesn't exist

#

if you are sure it exists, you need to assert it

#

using !

latent tiger
#

I had completely forgot about it

fresh pendant
#

!resolved