From 32f81d65b2eb4fc780d6479fdf6f666258334ec7 Mon Sep 17 00:00:00 2001 From: Peter Phanouvong Date: Thu, 27 Jun 2024 09:41:40 +1000 Subject: [PATCH] fix: env variables --- src/handlers/auth.js | 6 +++--- src/routerClients/AppRouterClient.js | 6 +++--- src/routerClients/PagesRouterClient.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/handlers/auth.js b/src/handlers/auth.js index 02b00d3..2e2796f 100644 --- a/src/handlers/auth.js +++ b/src/handlers/auth.js @@ -36,13 +36,13 @@ const getRoute = (endpoint) => { /** * @param {object} [request] * @param {string} [endpoint] - * @param {{onError?: () => void; config: {audience?: string | string[], clientId?: string, clientSecret?: string, issuerURL?: string, siteUrl?: string, postLoginRedirectUrl?: string, postLogoutRedirectUrl?: string}}} options + * @param {{onError?: () => void; config: {audience?: string | string[], clientId?: string, clientSecret?: string, issuerURL?: string, siteUrl?: string, postLoginRedirectUrl?: string, postLogoutRedirectUrl?: string}}} [options] * @returns {(req, res) => any} */ export default (request, endpoint, options) => { - if (!config.clientOptions.authDomain && !options?.config?.issuerURL) + if (!config.clientOptions.authDomain) throw new Error( - "env variable 'KINDE_ISSUER_URL' is not set and not passed in options" + "The environment variable 'KINDE_ISSUER_URL' is required. Set it in your .env file" ); if (!config.clientOptions.clientId && !options?.config?.clientId) diff --git a/src/routerClients/AppRouterClient.js b/src/routerClients/AppRouterClient.js index 275223a..b59f083 100644 --- a/src/routerClients/AppRouterClient.js +++ b/src/routerClients/AppRouterClient.js @@ -25,9 +25,9 @@ export default class AppRouterClient extends RouterClient { logoutRedirectURL: options?.config?.postLogoutRedirectUrl || config.clientOptions.logoutRedirectURL, - redirectURL: - `${options?.config?.siteUrl}/api/auth/kinde_callback` || - config.clientOptions.redirectURL, + redirectURL: options?.config?.siteUrl + ? `${options?.config?.siteUrl}/api/auth/kinde_callback` + : config.clientOptions.redirectURL, siteUrl: config.redirectURL || options.config.siteUrl }; this.kindeClient = createKindeServerClient( diff --git a/src/routerClients/PagesRouterClient.js b/src/routerClients/PagesRouterClient.js index a82139c..f519eeb 100644 --- a/src/routerClients/PagesRouterClient.js +++ b/src/routerClients/PagesRouterClient.js @@ -25,9 +25,9 @@ export default class PagesRouterClient extends RouterClient { logoutRedirectURL: options?.config?.postLogoutRedirectUrl || config.clientOptions.logoutRedirectURL, - redirectURL: - `${options?.config?.siteUrl}/api/auth/kinde_callback` || - config.clientOptions.redirectURL, + redirectURL: options?.config?.siteUrl + ? `${options?.config?.siteUrl}/api/auth/kinde_callback` + : config.clientOptions.redirectURL, siteUrl: config.redirectURL || options.config.siteUrl }; this.kindeClient = createKindeServerClient(