Refactor supabase.ts into modules
Refactor the supabase.ts file into smaller modules, separating test functionalities and default client configurations while preserving all code functionalities.
This commit is contained in:
29
src/lib/supabase/config.ts
Normal file
29
src/lib/supabase/config.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
// 온프레미스 Supabase URL과 anon key 설정
|
||||
export const getSupabaseUrl = () => {
|
||||
// 로컬 스토리지에서 설정된 URL을 우선 사용
|
||||
const storedUrl = localStorage.getItem('supabase_url');
|
||||
if (storedUrl) return storedUrl;
|
||||
|
||||
// 환경 변수 또는 기본값 사용
|
||||
return process.env.SUPABASE_URL || 'http://a11.ism.kr:8000';
|
||||
};
|
||||
|
||||
export const getSupabaseKey = () => {
|
||||
// 로컬 스토리지에서 설정된 키를 우선 사용
|
||||
const storedKey = localStorage.getItem('supabase_key');
|
||||
if (storedKey) return storedKey;
|
||||
|
||||
// 환경 변수 또는 기본값 사용
|
||||
return process.env.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzQyMDM5MzU4LCJleHAiOjQ4OTU2MzkzNTh9.XK0vetdwv_H2MHj4ewTfZGtSbrbSNDaV5xJhNo_Hdp8';
|
||||
};
|
||||
|
||||
// 온프레미스 연결을 위한 설정 도우미 함수
|
||||
export const configureSupabase = (url: string, key: string) => {
|
||||
// 로컬 스토리지에 설정 저장
|
||||
localStorage.setItem('supabase_url', url);
|
||||
localStorage.setItem('supabase_key', key);
|
||||
|
||||
// 페이지 새로고침 - 새로운 설정으로 Supabase 클라이언트 초기화
|
||||
window.location.reload();
|
||||
};
|
||||
Reference in New Issue
Block a user