0

I've been using massive.js within node for a couple months now and never ran into this error. I am completely stumped. Here is the code I am working with:

require('dotenv').config()

const{CONNECTION_STRING, SERVER_PORT, SESSION_SECRET} = process.env
const massive = require('massive')
const express = require('express')
const app = express()

const session = require('express-session')

app.use(express.json())

app.use(session({
    resave: true,
    saveUninitialized: false,
    secret: SESSION_SECRET,
    cookie: {
        maxAge: 1000 * 60 * 60 * 2
    }
}))

massive({
    connectionString: CONNECTION_STRING,
    ssl: {
        rejectUnauthorized: true
    }
})
.then(dbInstance => {
    app.set('db', dbInstance)
    app.listen(SERVER_PORT, () => console.log(`Server is bumping on ${SERVER_PORT}`))
})
.catch(err => console.log(err))

When I run nodemon, I get an error: "Error: self signed certificate". I know it has something to do with massive as when I take it out, nodemon connects to the server. When I change the value of rejectUnauthorized to false I get this error: "TypeError: client.ref is not a function". I have tried running "process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" on the command line and within the code but no luck. Any sort of help would be appreciated.

mnk802
  • 75
  • 6
  • in the massive ssl config, why do you have "rejectUnauthorized: true"? That's where your error is coming from. Set it to false if you don't have an authorized cert. – Erik Overflow Jul 27 '21 at 21:55
  • Setting it to false throws another error. When I change the value of rejectUnauthorized to false I get this error: "TypeError: client.ref is not a function". I – mnk802 Jul 27 '21 at 22:01

0 Answers0