diff --git a/src/main.ts b/src/main.ts index 819eadd..414fdee 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,6 +17,11 @@ if (!process.env.ADMINS) { process.exit(1); } +if (!process.env.ORIGIN) { + console.error("no origin found"); + process.exit(1); +} + const FILESIZE = process.env.FILESIZE_LIMIT if (!FILESIZE) { console.error("no file size detected"); @@ -28,10 +33,10 @@ if (!FILESIZE) { const PORT = process.env.PORT if (!PORT) { - console.error("no file size detected"); + console.error("no port detected"); process.exit(1); } else if (isNaN(Number(PORT)) && FILESIZE.trim() !== '') { - console.error("file size cannot be parsed."); + console.error("port cannot be parsed."); process.exit(1); } @@ -57,7 +62,7 @@ fastify.register(fastifyOauth2, { }, scope: ["identify"], startRedirectPath: '/login', - callbackUri: req => `${req.protocol}://${req.host}/login/callback`, + callbackUri: req => `${process.env.ORIGIN}/login/callback`, }) fastify.get('/login/callback', async function (request, reply) {