From 7b6c5fbbb0e3ca3aeb19ff1df947e781aceb6b87 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Fri, 12 Apr 2024 10:23:57 +0200 Subject: [PATCH] fix: grant: respect dynamic options (#503) --- src/routes/oauth/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routes/oauth/index.ts b/src/routes/oauth/index.ts index e4dcda235..fac19ad72 100644 --- a/src/routes/oauth/index.ts +++ b/src/routes/oauth/index.ts @@ -150,11 +150,15 @@ export const oauthProviders = Router() * @see {@link file://./config/index.ts} */ .use((req, res, next) => { - res.locals.grant = { - dynamic: { - origin: `${req.protocol}://${req.hostname}`, - }, - }; + if (!res.locals.grant) { + res.locals.grant = {}; + } + + if (!res.locals.grant.dynamic) { + res.locals.grant.dynamic = {}; + } + res.locals.grant.dynamic['origin'] = `${req.protocol}://${req.hostname}`; + next(); }) .use(grant.express(grantConfig))