@fszontagh I'm starting work on this issue now! I'll investigate why the newly added shop (id: 916103a0-db72-48fe-bff8-051b59a389) exists in the Supabase database but isn't showing up on the dashboard.
I'll check:
The database query used by the dashboard to fetch shops
Any filtering logic that might be excluding this shop
The frontend code that displays the shop list
Any potential user_id or authentication mismatches
@fszontagh I'm starting work on this issue now! I'll investigate why the newly added shop (id: 916103a0-db72-48fe-bff8-051b59a3890c) exists in the Supabase database but isn't showing up on the dashboard.
I'll check:
1. The database query used by the dashboard to fetch shops
2. Any filtering logic that might be excluding this shop
3. The frontend code that displays the shop list
4. Any potential user_id or authentication mismatches
I've investigated the issue and found that the shop does exist in the database with the correct user_id:
Shop ID: 916103a0-db72-48fe-bff8-051b59a3890c
User ID: d3d057cb-7585-48e3-8563-13bd491bb14d (ferenc.szontagh@smartbotics.ai)
Platform: WooCommerce
Store Name: woo.aicaller.hu
Status: is_active: true
The API endpoint that fetches stores (/api/stores) correctly filters by user_id, so the shop should be visible. Let me check a few more things:
Verify the API endpoint is working correctly
Check if there are any JavaScript errors in the frontend
Test the actual API call to see what's being returned
I'll need to test the Edge Function deployment to ensure it's using the latest code.
## Investigation Results
I've investigated the issue and found that the shop **does exist** in the database with the correct user_id:
- **Shop ID**: `916103a0-db72-48fe-bff8-051b59a3890c`
- **User ID**: `d3d057cb-7585-48e3-8563-13bd491bb14d` (ferenc.szontagh@smartbotics.ai)
- **Platform**: WooCommerce
- **Store Name**: woo.aicaller.hu
- **Status**: `is_active: true`
The API endpoint that fetches stores (`/api/stores`) correctly filters by user_id, so the shop should be visible. Let me check a few more things:
1. Verify the API endpoint is working correctly
2. Check if there are any JavaScript errors in the frontend
3. Test the actual API call to see what's being returned
I'll need to test the Edge Function deployment to ensure it's using the latest code.
Then it's getting the user from the token, but when querying the stores, RLS policies apply based on auth.uid(), which requires the Supabase client to be authenticated with the user's token, not just the anon key.
The Fix:
I need to create a Supabase client with the user's access token so that RLS policies work correctly with auth.uid().
Let me implement the fix now...
## Root Cause Identified
I've found the issue! The problem is with how the Edge Function (`/api`) is handling authentication and RLS policies.
**Here's what's happening:**
1. ✅ The store exists in the database with the correct `user_id`
2. ✅ The user exists in the `profiles` table
3. ✅ The RLS policies are correctly configured
4. ✅ A direct SQL query with the RLS policy logic returns the store correctly
**However**, the Edge Function at `supabase/functions/api/index.ts` is using the **anon key** to create the Supabase client:
```typescript
const supabaseUrl = Deno.env.get('SUPABASE_URL')!
const supabaseKey = Deno.env.get('SUPABASE_ANON_KEY')! // ❌ Using anon key
const supabase = createClient(supabaseUrl, supabaseKey)
```
Then it's getting the user from the token, but when querying the stores, RLS policies apply based on `auth.uid()`, which requires the Supabase client to be authenticated with the user's token, not just the anon key.
**The Fix:**
I need to create a Supabase client with the user's access token so that RLS policies work correctly with `auth.uid()`.
Let me implement the fix now...
I've successfully identified and fixed the bug. The new shop should now be visible on the dashboard!
What was the problem?
The Edge Function (supabase/functions/api/index.ts) was creating a Supabase client with only the anon key, without passing the user's access token. This meant that when querying the database, Row Level Security (RLS) policies couldn't properly identify the authenticated user using auth.uid().
The Solution
Modified the API Edge Function to pass the user's Authorization header when creating the Supabase client:
const supabase = createClient(supabaseUrl, supabaseKey, {
global: {
headers: {
Authorization: authHeader // Now includes user's token
}
}
})
This ensures that RLS policies can correctly match auth.uid() with the user's profile, allowing the stores query to return the user's shops.
Changes Made
✅ Updated supabase/functions/api/index.ts with proper authentication
✅ Deployed the fixed function to Supabase (version 3)
✅ Committed and pushed changes to repository (commit: e1eb856)
Testing
Please refresh your dashboard page. The shop "woo.aicaller.hu" (WooCommerce store) should now appear in your connected shops list.
If you still don't see it, please:
Hard refresh the page (Ctrl+Shift+R or Cmd+Shift+R)
Clear browser cache
Check browser console for any errors
Let me know and I'll investigate further!
## ✅ Bug Fixed and Deployed!
I've successfully identified and fixed the bug. The new shop should now be visible on the dashboard!
### What was the problem?
The Edge Function (`supabase/functions/api/index.ts`) was creating a Supabase client with only the anon key, without passing the user's access token. This meant that when querying the database, Row Level Security (RLS) policies couldn't properly identify the authenticated user using `auth.uid()`.
### The Solution
Modified the API Edge Function to pass the user's Authorization header when creating the Supabase client:
```typescript
const supabase = createClient(supabaseUrl, supabaseKey, {
global: {
headers: {
Authorization: authHeader // Now includes user's token
}
}
})
```
This ensures that RLS policies can correctly match `auth.uid()` with the user's profile, allowing the stores query to return the user's shops.
### Changes Made
1. ✅ Updated `supabase/functions/api/index.ts` with proper authentication
2. ✅ Deployed the fixed function to Supabase (version 3)
3. ✅ Committed and pushed changes to repository (commit: `e1eb856`)
### Testing
Please refresh your dashboard page. The shop "woo.aicaller.hu" (WooCommerce store) should now appear in your connected shops list.
If you still don't see it, please:
1. Hard refresh the page (Ctrl+Shift+R or Cmd+Shift+R)
2. Clear browser cache
3. Check browser console for any errors
4. Let me know and I'll investigate further!
@fszontagh The fix has been deployed and is now live! 🎉
You can test it immediately by visiting your dashboard at the Webshops page. The store should appear in the list without needing to add it again.
@fszontagh The fix has been deployed and is now live! 🎉
You can test it immediately by visiting your dashboard at the Webshops page. The store should appear in the list without needing to add it again.
Added new shop but on the dashboard it's not visible, not listed. In supabase table editor the shop exists (id:
916103a0-db72-48fe-bff8-051b59a389)@fszontagh I'm starting work on this issue now! I'll investigate why the newly added shop (id:
916103a0-db72-48fe-bff8-051b59a389) exists in the Supabase database but isn't showing up on the dashboard.I'll check:
Investigation Results
I've investigated the issue and found that the shop does exist in the database with the correct user_id:
916103a0-db72-48fe-bff8-051b59a3890cd3d057cb-7585-48e3-8563-13bd491bb14d(ferenc.szontagh@smartbotics.ai)is_active: trueThe API endpoint that fetches stores (
/api/stores) correctly filters by user_id, so the shop should be visible. Let me check a few more things:I'll need to test the Edge Function deployment to ensure it's using the latest code.
Root Cause Identified
I've found the issue! The problem is with how the Edge Function (
/api) is handling authentication and RLS policies.Here's what's happening:
user_idprofilestableHowever, the Edge Function at
supabase/functions/api/index.tsis using the anon key to create the Supabase client:Then it's getting the user from the token, but when querying the stores, RLS policies apply based on
auth.uid(), which requires the Supabase client to be authenticated with the user's token, not just the anon key.The Fix:
I need to create a Supabase client with the user's access token so that RLS policies work correctly with
auth.uid().Let me implement the fix now...
✅ Bug Fixed and Deployed!
I've successfully identified and fixed the bug. The new shop should now be visible on the dashboard!
What was the problem?
The Edge Function (
supabase/functions/api/index.ts) was creating a Supabase client with only the anon key, without passing the user's access token. This meant that when querying the database, Row Level Security (RLS) policies couldn't properly identify the authenticated user usingauth.uid().The Solution
Modified the API Edge Function to pass the user's Authorization header when creating the Supabase client:
This ensures that RLS policies can correctly match
auth.uid()with the user's profile, allowing the stores query to return the user's shops.Changes Made
supabase/functions/api/index.tswith proper authenticatione1eb856)Testing
Please refresh your dashboard page. The shop "woo.aicaller.hu" (WooCommerce store) should now appear in your connected shops list.
If you still don't see it, please:
@fszontagh The fix has been deployed and is now live! 🎉
You can test it immediately by visiting your dashboard at the Webshops page. The store should appear in the list without needing to add it again.