fix url encoded params for discord auth
This commit is contained in:
parent
dc84416985
commit
47e7baa4d5
|
@ -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}`);
|
||||
|
|
Loading…
Reference in New Issue