• Set authRequired to false then require authentication on specific routes.

    const { auth, requiresAuth } = require('express-openid-connect');

    app.use(
    auth({
    ...
    authRequired: false
    })
    );

    app.get('/profile', requiresAuth(), (req, res) => {
    res.send(`hello ${req.oidc.user.name}`);
    });

    Parameters

    • Optional requiresLoginCheck: ((req) => boolean)

    Returns RequestHandler