Having trouble logging out with @okta/oidc-middleware


I’m using node and Okta’s middleware in order to integrate Okta with my website. I am able to log in just fine, but I’m having trouble logging out. I’m trying to POST to the auto-generated /logout route, but I always get:

“UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘tokens’ of undefined”

I looked into the logout.js code, and saw that it had this line: “const tokens = req.userContext.tokens”, which is why it was considered undefined. I changed it so that it actually got the tokens from the request (by changing it to “req.body.userContext.tokens”), but now I’m getting “Unable to configure ExpressOIDC revokeError - undefined”.

Here is my code:

app.get(’/logout’, (req, res) => {
headers: {
‘content-type’: “application/json”
uri: ‘http://localhost:5002/logout’,
json: {“userContext”: req.userContext},
method: ‘POST’
}, function (err, res, body){

How do I fix it so that the user actually logs out? Was anyone else able to implement logout by using the middleware? Thanks!