managarten/chat/apps/mobile/utils/supabase.ts
Till-JS c638a7ffee feat(chat): integrate chat project into monorepo with full app structure
- Restructure chat as apps/mobile, apps/web, apps/landing, backend
- Add NestJS backend for secure Azure OpenAI API calls
- Remove exposed API key from mobile app (security fix)
- Add shared chat-types package
- Create SvelteKit web app scaffold
- Create Astro landing page scaffold
- Update pnpm workspace configuration
- Add project-level CLAUDE.md documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 13:48:24 +01:00

35 lines
1.1 KiB
TypeScript

import { createClient } from '@supabase/supabase-js';
const supabaseUrl = process.env.EXPO_PUBLIC_SUPABASE_URL || '';
const supabaseAnonKey = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY || '';
// Überprüfe, ob wir in einer Browser-Umgebung sind
const isBrowser = typeof window !== 'undefined';
// Importiere AsyncStorage nur, wenn wir in einer Browser-Umgebung sind
let AsyncStorage;
if (isBrowser) {
AsyncStorage = require('@react-native-async-storage/async-storage').default;
}
// Erstelle Supabase-Client mit unterschiedlichen Konfigurationen je nach Umgebung
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: isBrowser
? {
storage: AsyncStorage,
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
}
: {
// Dummy-Storage für serverseitiges Rendering
storage: {
getItem: () => Promise.resolve(null),
setItem: () => Promise.resolve(),
removeItem: () => Promise.resolve(),
},
autoRefreshToken: false,
persistSession: false,
detectSessionInUrl: false,
},
});