diff --git a/frontend/src/hooks.server.ts b/frontend/src/hooks.server.ts index 3d4c4c9..f0a94a2 100644 --- a/frontend/src/hooks.server.ts +++ b/frontend/src/hooks.server.ts @@ -59,12 +59,15 @@ const handleAuth: Handle = async ({ resolve, event }) => { throw redirect(303, '/login'); } - if (event.url.pathname === '/auth/discord') - throw redirect( - 302, - 'https://discord.com/api/oauth2/authorize?client_id=1099740412471672913&redirect_uri=http%3A%2F%2Flocalhost%3A5173%2Fauth%2Fcallback%2Fdiscord&response_type=code&scope=identify' - ); - else if (event.url.pathname === '/auth/callback/discord') { + if (event.url.pathname === '/auth/discord') { + const params = new URLSearchParams({ + client_id: env.CLIENT_ID, + redirect_uri: `${env.ORIGIN}/auth/callback/discord`, + response_type: 'code', + scope: 'identify' + }); + throw redirect(302, `https://discord.com/api/oauth2/authorize?${params.toString()}`); + } else if (event.url.pathname === '/auth/callback/discord') { const code = event.url.searchParams.get('code'); if (!code) { console.error(`failed to get code in callback url: ${event.url}`);