Menu

Never ship your OpenAI key: moving an LLM call into a Supabase Edge Function
📰

Never ship your OpenAI key: moving an LLM call into a Supabase Edge Function

DEV Community: reactnative·Luca·about 7 hours ago
#s9JhRi8O
#devtoreactnative#devto#dev#body#server
Long article (1808 words) — no AI summary yet.
Reading 0:00
15s threshold

The first version of my dream-reading app called OpenAI directly from the phone. The key sat in an EXPO_PUBLIC_ environment variable, which Expo inlines into the JavaScript bundle, which ships inside every copy of the app. Anyone with the APK and a little patience could have pulled it out and run their own workload on my bill.

I knew that on day one. The MVP's config file even said so, in a comment I wrote to myself:

// ⚠️ Anything bundled into a mobile app can be extracted from the binary. // This is fine for a local MVP, but before shipping to the stores move the // OpenAI call behind your own backend and keep the key on the server. export const OPENAI_API_KEY = process . env . EXPO_PUBLIC_OPENAI_API_KEY || '' ;

Enter fullscreen mode

Exit fullscreen mode

Six days later the call moved into a Supabase Edge Function.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.