suivox
suivox
CDCloudflare Developers
Created by suivox on 10/30/2024 in #general-help
Environment variables
Hey Im having trouble getting my final build of cloudflare to use my environment variables. This is my code
export async function onRequest(context) {
const supabaseConfig = {
supabaseUrl: context.env.LIVE_SUPABASE_URL,
supabaseKey: context.env.LIVE_SUPABASE_KEY
};

return new Response(JSON.stringify(supabaseConfig), {
headers: {
'Content-Type': 'application/json'
}
});
}
export async function onRequest(context) {
const supabaseConfig = {
supabaseUrl: context.env.LIVE_SUPABASE_URL,
supabaseKey: context.env.LIVE_SUPABASE_KEY
};

return new Response(JSON.stringify(supabaseConfig), {
headers: {
'Content-Type': 'application/json'
}
});
}
import { createClient } from '@supabase/supabase-js';

async function initializeSupabase() {
const response = await fetch('../functions/supabase-config');
try {
const { supabaseUrl, supabaseKey } = await response.json();

if (!response.supabaseUrl || !response.supabaseKey) {
throw new Error('Supabase configuration is incomplete');
}

return createClient(supabaseUrl, supabaseKey);
} catch (error) {
const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
const supabaseKey = process.env.REACT_APP_SUPABASE_ANON_KEY;

return createClient(supabaseUrl, supabaseKey);
}
}

const supabase = await initializeSupabase();

export default supabase;
import { createClient } from '@supabase/supabase-js';

async function initializeSupabase() {
const response = await fetch('../functions/supabase-config');
try {
const { supabaseUrl, supabaseKey } = await response.json();

if (!response.supabaseUrl || !response.supabaseKey) {
throw new Error('Supabase configuration is incomplete');
}

return createClient(supabaseUrl, supabaseKey);
} catch (error) {
const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
const supabaseKey = process.env.REACT_APP_SUPABASE_ANON_KEY;

return createClient(supabaseUrl, supabaseKey);
}
}

const supabase = await initializeSupabase();

export default supabase;
It skips to the local environment variable even in live production which tells me that the try catch is failing when the environment variable from cloudflare is being queried. Any ideas?
1 replies
CDCloudflare Developers
Created by suivox on 10/30/2024 in #general-help
Cant change email
Hey guys, my email that I signed up with had @gmai.com and isnt a real email. Im trying to change it but it wont let me without verifying the email I signed up with... Any ideas on how to change my email?
8 replies