Passport authentication

Error: secret option required for sessions

Not passing challenge:
https://learn.freecodecamp.org/information-security-and-quality-assurance/advanced-node-and-express/how-to-use-passport-strategies

I dont understand this error message because I have secret set to some string in the env file and passed as value of the key secret in the object passed to session()
did I put that snippet in the wrong place?

This is the app:

image

Looks like your glitch app is not available using the link you gave here.


here it is. The link above should work. receiving this error:

Error: secret option required for sessions
    at session (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express-session/1.16.2/node_modules/express-session/index.js:200:12)
    at Layer.handle [as handle_request] (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:317:13)
    at /rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:335:12)
    at next (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:275:10)
    at urlencodedParser (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/body-parser/1.19.0/node_modules/body-parser/lib/types/urlencoded.js:91:7)
    at Layer.handle [as handle_request] (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:317:13)
    at /rbd/pnpm-volume/b6f4ce85-637e-44e8-ad1e-fd13e0e4314f/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/router/index.js:284:7

Your .env file is missing a SESSION_SECRET variable.
Go in there and create a SESSION_SECRET and set its value to anything just like this

SESSION_SECRET='putanythinghere'
1 Like

I see now, another way would have been to change process.env.SESSION_SECRET to process.env.SECRET
in the server file and this is what Ive done as per their instructions in the glitch app