Advanced Node and Express - Set up Passport

Tell us what’s happening:
Describe your issue in detail here.
Cannot seem to pass the SESSION_SECRET test in the .env file; always results in: ‘Error: secret option required for sessions’
Your code so far

'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const app = express();

app.set('view engine', 'pug');
app.set('views', './views/pug');

app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,
  cookie: { secure: false }
}));

app.use(passport.initialize());
app.use(passport.session());

fccTesting(app); // For fCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.route('/').get((req, res) => {
  res.render('index', { title: 'Hello', message: 'Please log in' });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Listening on port ${PORT}`);
});

sample.env
SESSION_SECRET=“aaazxxsss”



**Your browser information:**

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

**Challenge:**  Advanced Node and Express - Set up Passport

**Link to the challenge:**
https://www.freecodecamp.org/learn/quality-assurance/advanced-node-and-express/set-up-passport

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.