export const GET = async ({ url, cookies }) => { const userCookie = cookies.get('user'); if (!userCookie) { return new Response('Unauthenticated', { status: 401 }); } const user = JSON.parse(userCookie); return Response.json( await ( await fetch('https://graphql.anilist.co', { method: 'POST', headers: { Authorization: `${user['token_type']} ${user['access_token']}`, 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify({ query: `mutation { SaveMediaListEntry(mediaId: ${ url.searchParams.get('id') || 'null' }, progress: ${url.searchParams.get('progress') || 'null'}) { id } }` }) }) ).json() ); };