From 337bc648ca5730c26f6150dae2db0c7c6e33b32c Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:07:22 +0100 Subject: [PATCH 1/2] fix(#14): Fix accessing private env var --- src/lib/utils/supabase/admin.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/utils/supabase/admin.ts b/src/lib/utils/supabase/admin.ts index 71a9439..a5a53eb 100644 --- a/src/lib/utils/supabase/admin.ts +++ b/src/lib/utils/supabase/admin.ts @@ -1,11 +1,8 @@ import { createClient } from '@supabase/supabase-js'; import stripe from 'stripe'; import type { Database, Tables, TablesInsert } from '$types/supabase'; -import { - PUBLIC_SUPABASE_URL, - SUPABASE_SERVICE_ROLE_KEY, - PUBLIC_STRIPE_SECRET_KEY -} from '$env/static/public'; +import { PUBLIC_SUPABASE_URL, PUBLIC_STRIPE_SECRET_KEY } from '$env/static/public'; +import { SUPABASE_SERVICE_ROLE_KEY } from '$env/static/private'; const toDateTime = (secs: number) => { const t = new Date(+0); // Unix epoch start. From 103ee16cecf9c5ff2cd446d2cefcf68a95931fe3 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:07:33 +0100 Subject: [PATCH 2/2] fix(#14): Fix invalid response --- src/routes/api/webhook/stripe/+server.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/api/webhook/stripe/+server.ts b/src/routes/api/webhook/stripe/+server.ts index 9b7b70b..a74d299 100644 --- a/src/routes/api/webhook/stripe/+server.ts +++ b/src/routes/api/webhook/stripe/+server.ts @@ -82,10 +82,9 @@ export const POST: RequestHandler = async ({ request }) => { } // Return a response to acknowledge receipt of the event - return { - status: 200, - body: { received: true } - }; + return new Response(JSON.stringify({ received: true }), { + status: 200 + }); } catch (err) { console.log(`Webhook Error: ${err.message}`); return {