diff --git a/src/auth.ts b/src/auth.ts index 359cabf..2c4ae5d 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -6,10 +6,9 @@ const API_ENDPOINT = 'https://discord.com/api/v6'; const axios = require('axios').default; export function run(app) { - const logger = app.get('logger'); - app.get('/discordauth', async (req, res) => { const code = req.query.code; + const url = `http://${req.headers.host}/discordauth`; if (code) { try { @@ -18,7 +17,7 @@ export function run(app) { client_secret: process.env.DISCORD_OAUTH_CLIENTSECRET, grant_type: 'authorization_code', code: code, - redirect_uri: 'http://localhost:8080/discordauth', + redirect_uri: url, scope: 'identify' }); @@ -60,10 +59,8 @@ export function run(app) { } catch(err) { res.send(`whoooops
${err}`); console.error(err); - logger.error(err); } } else { - const url = `http://${req.headers.host}/discordauth`; res.send(`Click here!!`); } });