-
Notifications
You must be signed in to change notification settings - Fork 2
feat(creator-packs): add RLS policy and integrate Supabase client #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "$schema": "https://opencode.ai/config.json", | ||
| "mcp": { | ||
| "supabase": { | ||
| "type": "remote", | ||
| "url": "https://mcp.supabase.com/mcp?project_ref=bmywdrwjdqmrkafhiuwn&features=docs%2Cdatabase%2Cdebugging%2Cdevelopment%2Cfunctions%2Cbranching", | ||
| "enabled": true | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { createClient } from '@supabase/supabase-js'; | |
| import type { Database } from './types'; | ||
|
|
||
| const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL as string; | ||
| const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_ANON_KEY as string; | ||
| const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY as string; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Either revert the rename to keep using the standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find any remaining references to the old env var name across the repo.
rg -nP '\bVITE_SUPABASE_ANON_KEY\b|\bSUPABASE_ANON_KEY\b' -C2
# Also check env example files.
fd -HI -t f '\.env' -x rg -nH 'SUPABASE' {}Repository: creatorcluster/renderdragon.org Length of output: 547 🏁 Script executed: #!/bin/bash
# 1. Verify the client.ts file has the new env var name
echo "=== Checking src/integrations/supabase/client.ts ==="
head -20 src/integrations/supabase/client.ts
# 2. Find all .env* files
echo -e "\n=== All .env* files in repo ==="
fd -HI '\.env' --type f
# 3. Check content of env example files
echo -e "\n=== Checking .env example files ==="
fd -HI '\.env.*example' --type f -x cat -n {}
# 4. Find all backend handlers (common patterns)
echo -e "\n=== Checking for SUPABASE env vars in all backend/api handlers ==="
rg -l 'VITE_SUPABASE|SUPABASE_(ANON|URL|KEY)' api/ --type js --type ts 2>/dev/null | head -20
# 5. Check all references to both old and new env var names
echo -e "\n=== All references to SUPABASE env vars (new and old) ==="
rg 'VITE_SUPABASE_(PUBLISHABLE_KEY|ANON_KEY)|SUPABASE_(ANON_KEY|PUBLISHABLE_KEY)' -nRepository: creatorcluster/renderdragon.org Length of output: 1235 Update backend to match renamed env var — this is a breaking change. The frontend now reads Update Since no 🤖 Prompt for AI Agents |
||
|
|
||
| // Import the supabase client like this: | ||
| // import { supabase } from "@/integrations/supabase/client"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| -- Drop existing policies if they exist to avoid conflicts | ||
| DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs; | ||
| DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs; | ||
|
|
||
| -- Allow anyone to read approved creator packs | ||
| CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs | ||
| FOR SELECT | ||
| USING (status = 'approved'); | ||
|
|
||
| -- Allow users to insert, update, and delete their own creator packs | ||
| CREATE POLICY "Users can manage their own creator packs" ON creator_packs | ||
| FOR ALL | ||
| USING (auth.uid() = user_id) | ||
| WITH CHECK (auth.uid() = user_id); | ||
|
|
||
| -- Allow admins to review creator packs | ||
| CREATE POLICY "Admins can review creator packs" ON creator_packs | ||
| FOR UPDATE | ||
| USING (auth.jwt() ->> 'email' = 'yamura@duck.com') | ||
| WITH CHECK (auth.jwt() ->> 'email' = 'yamura@duck.com'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opencode.jsonis an AI-IDE config file that encodes the Supabase project reference directly in the URL. While the project ref alone is not a secret key, committing IDE-specific tooling configs to the repository creates noise and unnecessarily exposes the project identifier. This file should be added to.gitignorerather than tracked.