Philo van Kemenade
10/17/2022, 3:32 PMAn error has occured: NetworkError when attempting to fetch resource.
any idea what might be causing this?Deed
10/17/2022, 4:09 PMexport const middleware: NextMiddleware = withMiddlewareAuth({
redirectTo: "/login",
authGuard: {
isPermitted: async (user): Promise<boolean> => {
const res = await supabase.rpc("user_has_any_role", {
user_id_: user.id,
});
return !!res.data;
},
redirectTo: "/unauthorized",
},
});
// See "Matching Paths" below to learn more
export const config = {
matcher: ["/((?!api|_next|fonts|login|unauthorized|[\\w-]+\\.\\w+).*)"],
};
Login.tsx
const handleLogin = async (email) => {
try {
setLoading(true);
const { error } = await supabase.auth.signInWithOtp({
email,
options: { emailRedirectTo: "/shows" },
});
if (error) throw error;
alert("Check your email for the login link!");
} catch (error) {
alert(error.error_description || error.message);
} finally {
setLoading(false);
}
};
dev Joakim Pedersen
10/17/2022, 4:18 PMVik
10/17/2022, 4:20 PMuser1234567890
.
As far as creating this function I'm creating a new SQL snippet that I have structured as so:
create or replace function random_username()
returns username as $$
declare
begin
end;
$$ language plpgsql security definer;
From here, I can't find much on how to future construct this function. Some docs I'm using are as follows:
https://www.techonthenet.com/postgresql/functions/random.php
I think the random() function would be perfect for this. How can I concat "user" + random numbers together in my function?
Again, I apologize this is probably super basic. I'm just so new to this that it looks harder than it seems.Jan Tennert
10/17/2022, 6:44 PMdev Joakim Pedersen
10/17/2022, 8:00 PMdwma
10/17/2022, 8:21 PMFirlefranz
10/17/2022, 8:37 PMIVOBOT
10/17/2022, 10:03 PMthestepafter
10/17/2022, 11:15 PMStiffJobs
10/18/2022, 1:45 AMBrams
10/18/2022, 3:00 AMthestepafter
10/18/2022, 3:13 AMShawn Conecone
10/18/2022, 5:57 AMid (Primary Key) | room_members(array of uid) | room_owner_uid (uid)
where:
- room_members is an array of the uid of authenticated users
- room_owner_id is the uid of the owner.
In the USING
expression, I tried to do:
uid() IN room_members
but it doesn't work.
A lot of example provided does not include this type of USING
expression, so I have not had any luck getting the right way to do this.
Anyone knows how to do this? Thanks!ray
10/18/2022, 7:01 AMSerj Hunt
10/18/2022, 11:02 AMNiklasPor
10/18/2022, 11:46 AMts
supabase
.channel('*')
.on('postgres_changes', { event: '*', schema: '*' }, (payload) => console.log(payload))
.subscribe();
I don't even see the messages for the specific missing tables inside the WS messages tab in Chrome. Also this only happens for 2 tables out of 20 and only on the hosted supabase variants, which really leaves me guessing 😄
Any help is appreciated!valentin ッ
10/18/2022, 1:16 PMBizzare
10/18/2022, 1:48 PMSacha
10/18/2022, 3:05 PMLukas V
10/18/2022, 4:03 PMconst getFullTextSearchIngredients = async (
queryString: string | undefined
) => {
let query = supabase
.from<SupabaseIngredient>('ingredients')
.select(
'*',
{
count: 'exact'
}
)
.order('popularity', { ascending: false })
.limit(20);
if (queryString) {
query = query.textSearch('product_name', queryString, {
type: 'phrase'
});
}
const { data, count, error } = await query;
if (error) {
throw new Error(`${error.message}: ${error.details}`);
}
if (count === 0) {
return null;
}
return data;
};
I pictured an example query, if you have a look "Chicken, broiler or fryes, breast, skinless..." should've been retrieved in both queries, but is only present in the first one.
Now, I do realise that the ingredient name is very obscure and could be renamed, however as I was reading docs there were different functions mentioned such as: to_tsvector()
to_tsquery()
@@
.
I don't understand what they do, but can they be included in supabase javascript method .textSearch()
to improve the search?
Or is it just postgres limitations and I should simply rename the ingredients 😁MrPreet
10/18/2022, 4:56 PMTomasz Szczuciński
10/18/2022, 5:44 PMDeed
10/18/2022, 6:11 PMexport const getServerSideProps: GetServerSideProps = withPageAuth({
redirectTo: "/login",
async getServerSideProps(ctx, supabase) {
const {
data: { user },
} = await supabase.auth.getUser();
const res = await supabase.rpc("user_has_any_role", {
user_id_: user?.id,
});
return {
redirect: !!res.data ? undefined : { destination: "/unauthorized" },
props: {},
};
},
});
Heres the login code
const handleLogin = async (email) => {
try {
setLoading(true);
const { error } = await supabase.auth.signInWithOtp({
email,
options: { emailRedirectTo: "/" },
});
if (error) throw error;
alert("Check your email for the login link!");
} catch (error) {
alert(error.error_description || error.message);
} finally {
setLoading(false);
}
};
logo
10/18/2022, 6:41 PMralusek
10/18/2022, 7:17 PMHTMHell
10/18/2022, 7:21 PMshopping_carts
table, and unauthenticated users can create a cart. When creating a cart, I'll use a token which will be stored in the client. I want to be able to restrict access to carts based on the token, so only a user who knows it can select / update it.
Any suggestions?Cazineer
10/18/2022, 8:46 PMerror
type AuthError
. I've tried searching for this type with no luck. Why is the Supabase documentation so obscure? I don't mean to be rude but providing clear and concise documentation on types (objects) and their methods/properties is fairly standard in 2022.
I'm basically stuck because the guides are dated and there does not seem to be updated documentation or any documentation for that matter that clearly states the properties and methods for simple things like the error object.
Thanks!drewbie
10/18/2022, 9:47 PM{
"statusCode": "404",
"error": "Not found",
"message": "The resource was not found"
}
I can also confirm that the images are in fact uploaded to the database, which I have to do by going to the Database tab in studio and changing the schema to storage since the Storage tab isn't there in local development Supabase.
The buckets are good as far as RLS goes, everything works fine with the same set up in a hosted environment, its just with local development.
I'm hoping to be able to view local images and that I am missing something obvious 🤷.
Thankscaseycrogers
10/18/2022, 11:27 PMhttp://localhost:3000
My additional redirect URL is io.supabase.castmeapp://login-callback/
Here's the redirect URL I'm getting:
https://magmdywarmnzoatbuesp.supabase.co/auth/v1/verify?<snipped>&type=signup&redirect_to=http://localhost:3000
The account gets verified, but I get redirected to localhost rather than getting redirected to the login callback.
Two questions:
1) What am I doing wrong, so that I can get things back into a working state?
2) How do I construct custom redirect URLs such that, if the user is on their phone, they get deep linked, but if the user is on their laptop (eg checked their email from a separate device) they go to my custom domain? Is there anything special about the format of the scheme? Can I use http/https
as my scheme and construct an app link as my redirect URL? How is Supabase auth picking what link to redirect to? Is it doing a naive string match on login-callback
for the host?