From 4ed0b3e8ddc598027f7975bbe033d802a6ddb3af Mon Sep 17 00:00:00 2001 From: bklaing2 Date: Sun, 23 Jun 2024 19:46:49 +0100 Subject: [PATCH] Added redirect from Spotify auth --- src/routes/auth/sign-in/+page.server.ts | 32 ++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/routes/auth/sign-in/+page.server.ts b/src/routes/auth/sign-in/+page.server.ts index 3119b8a..15b446b 100644 --- a/src/routes/auth/sign-in/+page.server.ts +++ b/src/routes/auth/sign-in/+page.server.ts @@ -1,24 +1,28 @@ +import { SPOTIFY_REDIRECT } from "$env/static/private"; import { redirect } from '@sveltejs/kit' const SCOPES = [ - 'user-follow-read', - 'playlist-read-private', - 'playlist-modify-public', - 'playlist-modify-private', - 'ugc-image-upload' + 'user-follow-read', + 'playlist-read-private', + 'playlist-modify-public', + 'playlist-modify-private', + 'ugc-image-upload' ] export const actions = { default: async ({ locals }) => { - const { data, error } = await locals.supabase.auth.signInWithOAuth({ - provider: 'spotify', - options: { scopes: SCOPES.join(' ') } - }) + const { data, error } = await locals.supabase.auth.signInWithOAuth({ + provider: 'spotify', + options: { + scopes: SCOPES.join(' '), + redirectTo: SPOTIFY_REDIRECT + } + }) - - if (error) throw new Error(error.message) - throw redirect(303, data.url as string) - } -} \ No newline at end of file + + if (error) throw new Error(error.message) + throw redirect(303, data.url as string) + } +}