Hi, I'm getting this error `TypeError: Cannot read properties of undefined (reading 'middleware')` w...
u
Hi, I'm getting this error
TypeError: Cannot read properties of undefined (reading 'middleware')
when setting up boilerplate session verification on my express server when I import this package like so:
import { verifySession } from 'supertokens-node/recipe/session/framework/express'
s
try this:
import { middleware } from "supertokens-node/framework/express";
u
Hey. I appreciate the response!
I'm not using the
middleware
method/function/class in this file and its corresponding express routes.
The error is being thrown in the
node_modules/supertokens-node/lib/build/framework/express/index.js
file.
Copy code
TypeError: Cannot read properties of undefined (reading 'middleware')
    at Object.<anonymous> (/Users/<me>/Desktop/casimir/node_modules/supertokens-node/lib/build/framework/express/index.js:19:49)
Does that make sense?
s
i believe so, are you trying to use verifySession like so:
Copy code
let app = express();

app.post("/like-comment", verifySession(), (req: SessionRequest, res) => {
    let userId = req.session!.getUserId();
    //....
});
u
Yes. But I am trying to use it on a
GET
request.
Could that be causing the issue?
s
that should still work
u
right. hm.
the error is being thrown every time I save my server. it doesn't build.
s
interesting what version of
supertokens-node
are you using?
u
"supertokens-node": "^13.1.2"
That was the first thing I tried (uninstalling, reinstalling, trying different versions, etc).
I also tried
"supertokens-node": "latest"
And I'm running node 18.4.x
SOLVED.
s
what was the issue, out of curiosity?
u
I was implementing that logic in a separate route that I was importing before initializing supertokens in my server main/index file.
Silly me.
260 Views