jt
10/13/2022, 12:49 AM매튜
10/13/2022, 3:44 AMexport const getServerSideProps = withPageAuth({
redirectTo: '/',
async getServerSideProps(ctx, supabaseServerClient) {
const { data } = await supabaseServerClient(ctx)
.from('users_vocabulary')
.select('*', { count: 'exact' });
return { props: { data } };
}
});
Followed the updated guide on https://github.com/supabase/auth-helpers/blob/main/packages/nextjs/README.md, supabase logs shows 200 query but then nothing shows up in chrome network monitor. Any ideas?fettuccine
10/13/2022, 5:13 AMcreate or replace function public.handle_new_user()
returns trigger as $$
begin
insert into public.profiles (id, email)
values (new.id->>id, new.email->>'email');
return new;
end;
$$ language plpgsql security definer;
and the trigger:
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
I'm using this so that my security rules have a record to check UID againstrbkayz
10/13/2022, 5:25 AMwhiskeywizard
10/13/2022, 5:57 AM<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js">
With the release of v2, the above will fetch the breaking changes and completely brick all production applications using the CDN method due to the change of supabase.auth.signIn.
The documentation should be updated to include a specific version in the CDN URL, at the very least.Shecky
10/13/2022, 6:36 AMAzura
10/13/2022, 7:09 AMTomCarnay
10/13/2022, 7:45 AMcats
10/13/2022, 8:57 AMrick4shar
10/13/2022, 10:08 AMpvtctrlalt
10/13/2022, 11:30 AMconst onSubmit = handleSubmit(async () => {
setLoading(true);
const userDetails:UserDetails = getValues();
const merged = {...customer, ...userDetails};
const res = await postData({
url: "/api/supa/updatecust",
data: merged
});
export const postData = async ({
url,
data
}: {
url: string;
data?: any;
}) => {
const res: Response = await fetch(url, {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
credentials: 'same-origin',
body: JSON.stringify(data)
});
if (!res.ok) {
console.log('Error in postData', { url, data, res });
throw Error(res.statusText);
}
const fresponse:any = await res.json();
return await fresponse;
};
then from the api folder i call a function in my supabase-admin in utils and return the results, this feels janky and weird
const updatecust = async (
req: NextApiRequest,
res: NextApiResponse
) => {
if (req.method === 'POST') {
try {
const test:UserDetails = req.body;
const cust = await updateCust(test);
res.status(200).json({ cust });
} catch (err:any) {
console.log(err);
res
.status(500)
.json({ error: { statusCode: 500, message: err.message } });
}
} else {
res.setHeader('Allow', 'POST');
res.status(405).end('Method Not Allowed');
}
};
is there a better way to do this? goal is to hide api key. but this feels weird 5 step proccess and jankyxuan
10/13/2022, 11:40 AMven
10/13/2022, 12:04 PMbabeard
10/13/2022, 12:28 PMsupabaseServerClient
was no longer available.
Suppose I wanted to createUser on the server side, is the recommended way going forward to use createClient with the service role key?Silver.
10/13/2022, 1:56 PMtyakymiuk
10/13/2022, 2:21 PMJeremy Deceuster
10/13/2022, 2:43 PMuseEffect(() => {
console.log("listening");
supabase
.channel("public:messages")
.on(
"postgres_changes",
{ event: "INSERT", schema: "public", table: "messages" },
(payload) => {
console.log("Change received!", payload);
}
)
.subscribe((status) => console.log(status));
}, []);
What I see in the console:
"listening"
"SUBSCRIBED"
Realtime is enabled, I removed StrictMode, tried older and version 2.0.0 of supabase/supabase-js.
Anyone can help me with this?enyo
10/13/2022, 2:47 PM.subscribe()
be invoked again with another status? Does supabase realtime have auto-reconnect capabilities or is this up to me to implement?peanuts
10/13/2022, 3:27 PMkvnfo
10/13/2022, 3:55 PMkhairulhaaziq
10/13/2022, 3:59 PMNicoNico
10/13/2022, 5:25 PMlifelesspizza
10/13/2022, 5:31 PMthestepafter
10/13/2022, 6:37 PMEthanxyz
10/13/2022, 9:06 PMtournaments
-
- id
- title
- matches ( FK id
field in t_matches
)
Table t_matches
- id
-created_at
- t_id ( FK id
field in tournaments
)
- t_match ( FK id
field in t_match
) -- Holds details about match
Table t_match
- id
- title
- state
- participants ( FK id
field of participants
table )
Table t_match_participants
- id
- match_id ( FK id
field of t_match
- participant ( FK id
for profiles
table )
The issue I am having is using this query...
js
let { data, error, status } = await supabase
.from("tournaments")
.select('*, matches(*, t_match(*, participants(*)))')
.eq("id", id).single();
Using this query ^ I am expecting to retrieve...
1. Multiple matches
, returning as an array since there are multiple matches in my database using the t_id
of 1
2. Multiple participants
, returning as an array since there are multiple participants for the given match_id
But instead I am only getting....
1. A single participant
object
2. A single match
object
Below I will post some photos of the Tables + Data. I would appreciate some help here. Thank you.
Image 1 - tournaments
Image2 - t_matches
Image3- t_match
Image4 - t_match_participants
Here is my current returned data...
json
{
"id":1,
"created_at":"...",
"title":"Test Tournament",
"min_participants":2,
"max_participants":5,
"start_time":null,
"matches":{
"id":1,
"created_at":"...",
"t_id":1,
"t_match":{
"id":1,
"created_at":"...",
"name":"Match Round 1",
"state":"ongoing",
"participants":{
"id":1,
"created_at":"...",
"match_id":1,
"participant":"48191...",
"isWinner":null
}
}
}
}
cbunge3
10/13/2022, 9:38 PMCheqo
10/13/2022, 9:54 PMdwma
10/13/2022, 11:52 PMcreate policy "Anyone can update an avatar." on storage.objects
for update with check (bucket_id = 'avatars');
Would that not allow a malicious user to update someone else's avatar? Is the security through obscurity of the object location/url? Or am I just misunderstanding something? An update doesn't produce a new URL, right? It changes the object at the referenced path so that the referenced avatar_url wouldn't change but the image at the end of the url would?Tony_n
10/14/2022, 12:21 AM-- Change host_activities and its sequence according to your table
CREATE OR REPLACE FUNCTION host_activities_null_id_is_default() RETURNS TRIGGER AS $$
BEGIN
NEW.id = coalesce(NEW.id, nextval('host_activities_id_seq'));
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER host_activities_null_id_is_default
BEFORE INSERT ON host_activities FOR EACH ROW EXECUTE PROCEDURE host_activities_null_id_is_default();
Chae
10/14/2022, 1:18 AM