Nextjs-auth0 - how to redirect after logout in a multi tenant app

I want to redirect my multitenant users to the page they were on after they logout

ie if a user on that secured page //domain/tenant1/securedpage logs out I want to redirect him to that same page. Or at the very least to the tenant’s home page, in that case //domain/tenant1

I understand that I have to whitelist the logout urls but when you’ve got 250 tenants how do you manage that when you have 100 pages per tenants?

Also how do you implement that when using the Nextjs-auth0 sdk?

Please help me, I’m blocked. thanks!

Ok so for the ones that want to know, I’m not sure still if I can have some sort of wild card that’d allow me to redirect to whatever page I want without registering it first in the allowed logout url at the auth0 level.

So if I have 250 tenants to cater for I’ll have to enter 250 urls manually ;(

as for the implementation in the front end, I do it like so:

export default async function logout(req, res) {
    const { query: { returnTo } } = req;
    try {
        await auth0.handleLogout(req, res, { returnTo: `http://localhost:9090/${returnTo}` });
    } catch (error) {
        res.status(error.status || 500).end(error.message);

and I can then specify whatever path I want in the query string

{hasAccess && <MeButton url={`/api/logout?returnTo=${clientAlias}`} displayText={'Logout'} />}

hope it helps

If anyone has an answer for the allowed logout urls, I’d appreciate