question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`express-session deprecated req.secret; provide secret option`: after adding `connect-mongo` and configuring its receiver

See original GitHub issue

Node version: Sails version (sails): 1.2.3 ORM hook version (sails-hook-orm): 2.1.1 Sockets hook version (sails-hook-sockets): 2.0.0 Organics hook version (sails-hook-organics): 1.0.0 Grunt hook version (sails-hook-grunt): nil Uploads hook version (sails-hook-uploads): 0.4.3 DB adapter & version (e.g. sails-mysql@5.55.5): 1.0.1 Skipper adapter & version (e.g. skipper-s3@5.55.5): nil


Hello, when i installed a fresh app, i encountered an error while trying to plug in the sessions adapter into it’s receiver

The receivers config is as follows:

module.exports.session = {
  secret: "7fdca2c7ecdc07c00c6edd4566ffee57",
  adapter: "connect-mongo",
  url: "mongodb://localhost:27017/smapp-sessions",
//.. some lines where ommited
}

Error @sailsConsole

express-session deprecated req.secret; provide secret option node_modules/.registry.npmjs.org/sails/1.2.3/node_modules/sails/lib/hooks/session/index.js:451:62
### Server lifted below this line successfully, and the flag is up ###

but then an error occurred while trying to render the page /

Error occurred in session middleware :: 'Error: secret option required for sessions\n at session ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express-session/1.15.6/node_modules/express-session/index.js:199:12)\n' + ' at app._privateSessionMiddleware ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/sails/1.2.3/node_modules/sails/lib/hooks/session/index.js:463:18)\n' + ' at session ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/sails/1.2.3/node_modules/sails/lib/hooks/http/get-configured-http-middleware-fns.js:83:9)\n' + ' at Layer.handle [as handle_request] ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/layer.js:95:5)\n' + ' at trim_prefix ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:317:13)\n' + ' at ' + '/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:284:7\n' + ' at Function.process_params ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:335:12)\n' + ' at next ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:275:10)\n' + ' at cookieParser ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/cookie-parser/1.4.3/node_modules/cookie-parser/index.js:70:5)\n' + ' at Layer.handle [as handle_request] ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/layer.js:95:5)\n' + ' at trim_prefix ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:317:13)\n' + ' at ' + '/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:284:7\n' + ' at Function.process_params ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:335:12)\n' + ' at next ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/index.js:275:10)\n' + ' at startRequestTimer ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/sails/1.2.3/node_modules/sails/lib/hooks/http/initialize.js:303:11)\n' + ' at Layer.handle [as handle_request] ' + '(/home/navicstein/Codes/smapp/node_modules/.registry.npmjs.org/express/4.16.2/node_modules/express/lib/router/layer.js:95:5)'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
navicsteincommented, Jul 17, 2019

Hello, i have resolved this issue by installing a lower version of connect-mongo

pnpm install connect-mongo@2.0.3  --save-exact 

An after those, depreciation notice was gone, seems like the sails team @madisonhicks @johnabrams7 @tedkulp @sailsbot needs to update sails to support connect-mongo@latest

2reactions
redwildfire13commented, Feb 3, 2020

I have the same issues when using connect-mongo 3.2.0. Following it through on the debugger, it looks like its because connect-mongo deletes the secret option after applying it to the store in index.js line 76. I’m not sure how to get around this but maybe it’s an issue there? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

express-session deprecated req.secret ... - Stack Overflow
Make sure you added the SESSION_SECRET in .env file. If yes, then in your app.js, add this. const dotenv = require('dotenv').config().
Read more >
express-session deprecated req.secret; provide secret option ...
I couldn't add or find .env file, so I used Secrets (Environment variables) to create const mySecret in connection.js file. key: MONGO_URL ...
Read more >
Express-session tutorial, Express session domain, Cannot find ...
`express-session deprecated req.secret; provide secret option`: after ... secret option`: after adding ` connect-mongo` and configuring its receiver #6810.
Read more >
typeerror('router.use() requires a middleware function but got ...
When i run npm start in my expressConfusionServer ... provide resave option index.js:26:9 express-session deprecated undefined saveUninitialized option; ...
Read more >
third party component notices - Starry Internet
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found