Fix missing env variable during build time
Some checks failed
Build Docker image / build (pull_request) Has been cancelled
Some checks failed
Build Docker image / build (pull_request) Has been cancelled
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.svelte-kit/
|
.svelte-kit/
|
||||||
|
.env
|
||||||
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
PUBLIC_SUPABASE_URL=https://abc.supabase.co
|
||||||
|
PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI16C_s
|
||||||
@@ -2,7 +2,7 @@ import { createServerClient } from '@supabase/ssr'
|
|||||||
import { type Handle, redirect } from '@sveltejs/kit'
|
import { type Handle, redirect } from '@sveltejs/kit'
|
||||||
import { sequence } from '@sveltejs/kit/hooks'
|
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 }) => {
|
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.
|
* 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: {
|
cookies: {
|
||||||
getAll: () => event.cookies.getAll(),
|
getAll: () => event.cookies.getAll(),
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createBrowserClient, createServerClient, isBrowser } from '@supabase/ssr'
|
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'
|
import type { LayoutLoad } from './$types'
|
||||||
|
|
||||||
export const load: LayoutLoad = async ({ data, depends, fetch }) => {
|
export const load: LayoutLoad = async ({ data, depends, fetch }) => {
|
||||||
@@ -10,12 +10,12 @@ export const load: LayoutLoad = async ({ data, depends, fetch }) => {
|
|||||||
depends('supabase:auth')
|
depends('supabase:auth')
|
||||||
|
|
||||||
const supabase = isBrowser()
|
const supabase = isBrowser()
|
||||||
? createBrowserClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
|
? createBrowserClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, {
|
||||||
global: {
|
global: {
|
||||||
fetch,
|
fetch,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
|
: createServerClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, {
|
||||||
global: {
|
global: {
|
||||||
fetch,
|
fetch,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user