Env variable returns undefined

Tell us what’s happening:
I can’t set express session because the secret env variable returns undefined.

Error: secret option required for sessions
at session (/home/runner/boilerplate-advancednode-1/node_modules/express-session/index.js:200:12)
at Layer.handle [as handle_request] (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:323:13)
at /home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:341:12)
at next (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/home/runner/boilerplate-advancednode-1/node_modules/body-parser/lib/types/urlencoded.js:91:7)
at Layer.handle [as handle_request] (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:323:13)
at /home/runner/boilerplate-advancednode-1/node_modules/express/lib/router/index.js:284:7

Your code so far
https://boilerplate-advancednode-1.ggrass1585.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Set up Passport

Link to the challenge:

Try using the secrets tab on replit to set environment variables, .env files are deprecated.

1 Like