diff --git a/.dockerignore b/.dockerignore index e7ad765..858c169 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ node_modules/ -.svelte-kit/ \ No newline at end of file +.svelte-kit/ +.env \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e3df937 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +PUBLIC_SUPABASE_URL=https://abc.supabase.co +PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI16C_s \ No newline at end of file diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 079d393..09e2560 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -2,7 +2,7 @@ import { createServerClient } from '@supabase/ssr' import { type Handle, redirect } from '@sveltejs/kit' import { sequence } from '@sveltejs/kit/hooks' -import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public' +import { env } from '$env/dynamic/public' const supabase: Handle = async ({ event, resolve }) => { /** @@ -10,7 +10,7 @@ const supabase: Handle = async ({ event, resolve }) => { * * The Supabase client gets the Auth token from the request cookies. */ - event.locals.supabase = createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, { + event.locals.supabase = createServerClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, { cookies: { getAll: () => event.cookies.getAll(), /** diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 7a40abc..46d5417 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,5 +1,5 @@ import { createBrowserClient, createServerClient, isBrowser } from '@supabase/ssr' -import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public' +import { env } from '$env/dynamic/public' import type { LayoutLoad } from './$types' export const load: LayoutLoad = async ({ data, depends, fetch }) => { @@ -10,12 +10,12 @@ export const load: LayoutLoad = async ({ data, depends, fetch }) => { depends('supabase:auth') const supabase = isBrowser() - ? createBrowserClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, { + ? createBrowserClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, { global: { fetch, }, }) - : createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, { + : createServerClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, { global: { fetch, },