ashwan
05/11/2023, 9:50 AMH1GHG2M3R
05/11/2023, 10:29 AMexport async function getServerSideProps() {
let { data } = await supabase
.from("products")
.select("*")
.eq("product_is_active", true);
return {
props: {
products: data,
},
};
}
This does not return any data at all.
Posting to the same table using: const { data, error } = await supabase.from("products").insert([{ product_name: name, product_category: category }]);
returns "new row violates row-level security policy for table \"products\""Юрец Огурец
05/11/2023, 10:36 AMzensin
05/11/2023, 11:07 AMMerovingian
05/11/2023, 12:47 PMven
05/11/2023, 1:24 PM-- table public.profile
alter table public.profile enable row level security;
drop policy if exists "RLS for public.profile" ON public.profile;
create policy "RLS for public.profile"
on public.profile
for all using (
auth.uid()::text = user_uid
);
I invoke the unit test with
deno test --allow-net --allow-env --allow-read --import-map ./functions/import_map.json ./functions/profile/profile.test.ts
the supabase client gets instantiated so
const supabaseClient = createClient(
Deno.env.get("SUPABASE_URL"),
Deno.env.get("SUPABASE_ANON_KEY"),
);
but this is using a ANON key. how does this get overwritten by a logged in user?
Please let me know if you need more information to help. thanksDilly
05/11/2023, 1:49 PMmaikeriva
05/11/2023, 2:05 PMimport { createClient } from '@supabase/supabase-js'
import { ThemeSupa } from '@supabase/auth-ui-shared'
import { Auth } from '@supabase/auth-ui-react'
const supabase = createClient(
import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_ANON_KEY
)
function App() {
return (
<div className="flex items-center justify-center h-screen">
<div className="container max-w-sm p-6 grid place-items-center">
<h1 className="text-4xl pb-4">
My app
</h1>
<Auth
supabaseClient={supabase}
appearance={{
theme: ThemeSupa,
variables: {
default: {
colors: {
brandAccent: `pink`,
},
},
},
}}
providers={['google']}
redirectTo="https://example.org/"
theme="dark"
/>
</div>
</div>
)
}
export default App
As you can see, the redirectTo parameter is set to "https://example.org", just for testing. https://example.org has also been added among the allowed redirects in the Supabase Auth configuration page.
And yet, when I sign in through the app it does nothing. Signing in with Google redirects instead to the default website URL (which is not what specified in redirectTo).
Am I mistaking what redirectTo actually does? (I could find no documentation about it). Maybe it is because I am running the app locally?
I saw several posts about this issue but none has a solution provided.talpiven
05/11/2023, 2:23 PMosamita
05/11/2023, 2:52 PMflapopo
05/11/2023, 3:30 PMsql
create table if not exists public.location (
cap text primary key,
coordinate geography(POINT) not null
);
create or replace function nearby_locations(lat float, long float)
returns setof record
language sql
as $$
select cap, st_astext(coordinate) as coordinate, st_distance(coordinate, st_point(long, lat)::geography) as dist_meters
from public.location;
$$;
dart
void callRPC() async {
final data = await supabase.rpc('nearby_locations', params: {
'lat': 43.1891251,
'long': 13.510635,
});
print(data);
// [{cap: ..., coordinate: ..., dist_meters: 4430219.90138175}]
}
What is 4430219.90138175
? How can i format in meter, i know that the difference between this coordinate from me is 10 km, how can we get back 10.000 meters?
Thanks so much.Jon
05/11/2023, 3:42 PMvar channel = supabase.Realtime.Channel("realtime", "public", "countries", "id", "id=eq.200");
channel.OnMessage += (sender, args) =>
{
Debug.WriteLine(args.Response.Payload);
};
await channel.Subscribe();
And it flat out didn't work, so I eventually managed to get this approach working
supabase.Realtime.Connect().OnMessage += (sender, args) => { Debug.Log($"Something changed on the server");};
channel = supabase.Realtime.Channel("realtime", "public", "people", "id", result.Result.User.Id);
channel.OnUpdate += (object sender, PostgresChangesEventArgs e) =>
{
LiveProfile = e.Response.Model<UserProfile>();
Debug.Log($">>>>>>>>{LiveProfile.email} has been updated ");
};
await channel.Subscribe();
Which seemed to work
But then every now & then I see that the realtime logs record that realtime gets shut down because noone is logged in
Stop tenant mytenantthing because of no connected users
So I make sure that I login in via the api (obviously I'm logged in on the dash) and it still doesn't 'wake-up' the realtime stuff. any pointers on how to get this working reliably would be appreciated.aar2dee2
05/11/2023, 4:25 PMPKCE
auth flow is available for my project. Can this be used to access session
and database data inside getStaticProps
and getServerSideProps
without using the serverClient
from auth-helpers
?NanoBit
05/11/2023, 4:43 PMauthenticated
monsieurlazar
05/11/2023, 5:06 PMmendrinos
05/11/2023, 5:12 PMSELECT operators
FROM interactions
WHERE operators @> '[{"supabase_user_id": "a9afe17f-5bb9-4082-aaff-40bb1992a009"}]'
OR reviewers @> '[{"supabase_user_id": "a9afe17f-5bb9-4082-aaff-40bb1992a009"}]'
OR clients @> '[{"supabase_user_id": "a9afe17f-5bb9-4082-aaff-40bb1992a009"}]'
It would be great if someone could suggest to me that way I can achieve the same by using the serverSupabaseClient api.
I tried this:
const queryConditions = {
'operators': {
'@>': [{ supabase_user_id: 'a9afe17f-5bb9-4082-aaff-40bb1992a009' }]
}
}
const { data, error } = await client
.from('interactions')
.select('operators')
.match(queryConditions)
But it does not work.Dilly
05/11/2023, 5:12 PMx-upsert
header to true
to make it overwrite any existing "logo.png" file.
3. When the upload completes, I use Supabase Javascript CLI to download the image, and then I create an object URL from it:
const { data, error } = await supabase.storage.from('organization').download('logo.png')
if (!error && data) {
orgLogoSrc.value = URL.createObjectURL(data)
}
This all works, but sometimes the logo doesn't refresh to the new one. It seems very random too, as sometimes it works and sometimes it doesn't. I'm not sure why, because I'm creating a unique object URL each time, so I think the .download()
call is returning the wrong image data.
I would like to keep the name of the file a static "logo.png" while avoiding these issues if possible. I know I can create a unique name each time but I'm trying to keep things as simple as possible. If I have a random, unique name for the organization logo then I would have some extra steps such as deleting the old files and determining what the name is (I'd have to store it in the db or something).
This has to be a common scenario and I'm sure there's a better way to go about doing this. I'm looking for what the best practice is to accomplish this.anindosarker
05/11/2023, 5:54 PMEddydpyl
05/11/2023, 5:54 PMbombillazo
05/11/2023, 6:34 PMstrajk
05/11/2023, 7:38 PMOneZero
05/11/2023, 8:13 PMGuy Rozen
05/11/2023, 8:28 PMformigueiro
05/11/2023, 9:37 PMjs
CREATE TABLE urls (
_id SERIAL PRIMARY KEY,
slug VARCHAR(255),
url VARCHAR(255) NOT NULL UNIQUE,
shortened VARCHAR(255) UNIQUE,
ip VARCHAR(255) NOT NULL,
clicks INT NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
user_id INT NOT NULL REFERENCES users(_id) ON DELETE CASCADE
);
so i would like to add relation to auth.user
but its not workingosamita
05/11/2023, 10:26 PMrovrav
05/11/2023, 10:26 PMimport { createClient } from '@supabase/supabase-js'
import AsyncStorage from "@react-native-async-storage/async-storage";
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", {
auth: {
storage: AsyncStorage,
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
},
});
The example above is for React Native but what is the optimal implementation for a chrome extension?
https://supabase.com/docs/reference/javascript/initializinggaryaustin
05/11/2023, 10:37 PMRodrigo702
05/11/2023, 10:56 PMhttps://cdn.discordapp.com/attachments/1106354163052458086/1106354163220238407/Screenshot_2023-05-11_at_3.53.50_PM.png▾
tylerclark
05/11/2023, 11:10 PMLDs_Group
05/12/2023, 12:27 AMdart
@override
Stream<bool> onAuthStateChange() async* {
bool isLoggedIn = false;
log('====| started |====');
_goTrueClient.onAuthStateChange.listen((data) {
log('--auth state--');
isLoggedIn = data.session == null;
});
log('====| ended |====');
yield isLoggedIn;
}
with the logs, I get following results:
m
====| started |====
====| ended |====
but I don't get --auth state--