diff --git a/discord.js b/discord.js index 18797e6..1d5ca42 100644 --- a/discord.js +++ b/discord.js @@ -6,7 +6,10 @@ const BOT_SECRET = "vhk6jp_jYjvShOqpI8MJ2Efjjm_9Cmyi"; exports.handleDiscordAuth = async (request, reply) => { const protocol = request.protocol || (request.headers['x-forwarded-proto'] || '').split(',')[0] || 'http'; - const host = request.hostname || request.headers.host; + let host = request.hostname || request.headers.host; + if (host == 'localhost') { + host = host + ":3000"; + } const REDIRECT_URI = `${protocol}://${host}/auth/discord/callback`; const code = request.query.code; diff --git a/routes/other.js b/routes/other.js index d8037f3..4b86d1f 100644 --- a/routes/other.js +++ b/routes/other.js @@ -11,7 +11,10 @@ module.exports = async function (app, opts) { // --- Auth Discord --- app.get('/auth/discord', async (req, reply) => { const protocol = req.protocol || (req.headers['x-forwarded-proto'] || '').split(',')[0] || 'http'; - const host = req.hostname || req.headers.host; + let host = req.hostname || req.headers.host; + if (host == 'localhost') { + host = host + ":3000"; + } const redirectUri = `${protocol}://${host}/auth/discord/callback`; const clientId = '1410578978712060024';