diff --git a/src/app.d.ts b/src/app.d.ts index a1e9f5e..8fa09e5 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -122,13 +122,6 @@ declare global { servername: string } - interface AuthData { - User: { - Id: string - } - AccessToken: string - } - interface User { Name: string Id: string diff --git a/src/routes/api/jellyfin/auth/+server.ts b/src/routes/api/jellyfin/auth/+server.ts index c8b926f..5443c82 100644 --- a/src/routes/api/jellyfin/auth/+server.ts +++ b/src/routes/api/jellyfin/auth/+server.ts @@ -30,8 +30,11 @@ export const POST: RequestHandler = async ({ request, fetch }) => { }) if (!authResponse.ok) return new Response('Failed to authenticate', { status: 401 }) - const authData: Jellyfin.AuthData = await authResponse.json() - return Response.json(authData) + const authData = await authResponse.json() + return Response.json({ + userId: authData.User.Id, + accessToken: authData.AccessToken, + }) } catch { return new Response('Fetch request failed', { status: 404 }) } diff --git a/src/routes/settings/connections/+page.server.ts b/src/routes/settings/connections/+page.server.ts index bac692a..87302ce 100644 --- a/src/routes/settings/connections/+page.server.ts +++ b/src/routes/settings/connections/+page.server.ts @@ -36,15 +36,15 @@ export const actions: Actions = { return fail(500, { message: 'Internal Server Error' }) } - const authData: Jellyfin.AuthData = await jellyfinAuthResponse.json() + const authData = await jellyfinAuthResponse.json() const serviceData: Jellyfin.JFService = { type: 'jellyfin', - userId: authData.User.Id, + userId: authData.userId, urlOrigin: serverUrl.toString(), } const tokenData: Jellyfin.JFTokens = { - accessToken: authData.AccessToken, + accessToken: authData.accessToken, } const newConnectionResponse = await fetch(`/api/users/${locals.user.id}/connections`, { diff --git a/svelte.config.js b/svelte.config.js index 2b35fe1..ecdd6d8 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,18 +1,22 @@ -import adapter from '@sveltejs/adapter-auto'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; +import adapter from '@sveltejs/adapter-auto' +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' /** @type {import('@sveltejs/kit').Config} */ const config = { - // Consult https://kit.svelte.dev/docs/integrations#preprocessors - // for more information about preprocessors - preprocess: vitePreprocess(), + // Consult https://kit.svelte.dev/docs/integrations#preprocessors + // for more information about preprocessors + preprocess: vitePreprocess(), - kit: { - // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. - // If your environment is not supported or you settled on a specific environment, switch out the adapter. - // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() - } -}; + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter(), + csrf: { + // REMOVE THIS WHEN SHIPPING + checkOrigin: false, + }, + }, +} -export default config; +export default config