From 17822fb4ec6f02ed36fed46ac0c6eda45ebbbe72 Mon Sep 17 00:00:00 2001 From: Ore O Date: Sun, 7 Apr 2024 09:54:36 +0100 Subject: [PATCH] fix: dynamic redirectUri neurosity --- server/controllers/neurosity.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/controllers/neurosity.js b/server/controllers/neurosity.js index 94278576..2d34e8e4 100644 --- a/server/controllers/neurosity.js +++ b/server/controllers/neurosity.js @@ -5,11 +5,15 @@ const neurosity = new Neurosity({ }); exports.generateOAuthURL = async (req, res) => { - await neurosity + const redirectUri = + process.env.NEUROSITY_OAUTH_CLIENT_REDIRECT_URI ?? + `https://${req.hostname}/neurosity-callback`; + + await neurosity .createOAuthURL({ clientId: process.env.NEUROSITY_OAUTH_CLIENT_ID, clientSecret: process.env.NEUROSITY_OAUTH_CLIENT_SECRET, - redirectUri: process.env.NEUROSITY_OAUTH_CLIENT_REDIRECT_URI, + redirectUri: redirectUri, responseType: "token", state: Math.random().toString().split(".")[1], // A random string is required for security reasons scope: [