death_wears_bunny_slippers
10/02/2022, 11:16 PMpages/index.js
getServerSideProps()
redirects to my signin page. This is intermittent although it seems to be happening more frequently in the last few hours. When this happens, if I wait a minute or two it sometimes just magically redirects to the home page. So perhaps this is a latency issue as far as setting the session on Supabase?
2. After authenticating, calling req.cookies["sb-access-token"]
in an API route sometimes returns undefined
. This too is intermittent. Other times I can see the cookie and it matched what I see in the developer tools.
Has anyone else had a similar issue? Is there anything specific I should try?Brams
10/03/2022, 12:21 AMgaryaustin
10/03/2022, 1:01 AMCREATE OR REPLACE FUNCTION run_explain()
RETURNS SETOF text AS
$$
BEGIN
// more stuff here
RETURN QUERY
EXPLAIN ANALYZE SELECT * FROM messages;
END
$$ LANGUAGE plpgsql;
select * from run_explain();
This does not work for same reason above. Supabase SQL editor just returns successful and Datagrip asks which command to run.
Is there anyway to create/replace a function and get the result in the SQL editor I'm missing?
Otherwise doing two separate windows with the create and select I assume is as good as it gets.BoogersLLC
10/03/2022, 1:05 AMinvoke
function catches the error (and then populates error
instead of data
)
I'm also pretty confused because if I try to just throw new Error('some error')
instead of returning a response, I get a CORS Policy block. So it seems like I must return a response with my CORS headers, but then I'm not sure how to return an error at that point?
I'm also a total Deno noob, so I may be missing something really obvious here.Elector
10/03/2022, 2:39 AMevent {
id: UUID
}
category: {
id: int,
name: text
}
criterion: {
question: text
category_id: FK -> category
}
event_category {
event_id: FK -> event
category_id: FK -> category
}
So, each category has various criteria. And an event can have various categories. What I can't seem to do is answer the question: "For this event, what are all the criteria that apply?"
This is what I have so far. I can get to the category, but I can't get across the intermediary table:
javascript
let { data, error, status } = await supabase
.from('criterion')
.select('category_id, question, category_id!inner(name)')
.eq('category_id.name', 'Event');
I know my from table needs to be criterion, and I know I need go to up from criterion to category (with an inner join, and I've made this happen). I know I also need to go across event_category, but I can't seem to work out the supabase query for that. If anyone could provide advice, it would be greatly appreciated.user8923
10/03/2022, 3:00 AMcorasan
10/03/2022, 4:14 AMv2.0.0-rc.10
, and it works fine when I point my application to the remote db, but when I point it to my local environment it doesn't get any updates. I checked the state of each channel and they all say "joined". I checked the logs as well and I can see that it JOINED realtime:xxxx
.Bruce Wang
10/03/2022, 4:40 AMMonky
10/03/2022, 9:38 AMts
// Components
import { ThemeProvider } from 'next-themes';
import { UserProvider } from '@supabase/auth-helpers-react';
// Variables
import { supabaseClient } from '@supabase/auth-helpers-nextjs';
// Styles
import '../styles/globals.css';
// Types
import type { ReactElement, ReactNode } from 'react';
import type { NextPage } from 'next';
import type { AppProps } from 'next/app';
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
};
interface AppPropsWithLayout extends AppProps {
Component: NextPageWithLayout;
}
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
const getLayout = Component.getLayout ?? ((page) => page);
return getLayout(
<UserProvider supabaseClient={supabaseClient}>
<ThemeProvider attribute="class">
<Component {...pageProps} />
</ThemeProvider>
</UserProvider>
);
}
export default MyApp;
``api/auth/[...supabase].ts``
ts
import { handleAuth } from '@supabase/auth-helpers-nextjs';
export default handleAuth({ logout: { returnTo: '/' } });
This is the error generated by the ``useUser`` hook: ``The request to /api/auth/user failed!``
And here the ``UserProvider`` console error: ``GET http://localhost:3000/api/auth/user 404 (Not Found)``cdedreuille
10/03/2022, 11:02 AMconst file = e.target.files[0];
let formData = new FormData();
formData.append("file", file);
const { data, error } = await supabaseClient.functions.invoke(
"media-upload",
{
body: JSON.stringify({
file: formData,
}),
}
);
This is how I send my file to the edge function but inside the function I can't do file.getAll("file")
.
Anyone knows what I'm doing wrong?daveteu
10/03/2022, 11:48 AMrishav
10/03/2022, 12:27 PMSherlock7
10/03/2022, 12:53 PMMokamars
10/03/2022, 2:14 PMgaryaustin
10/03/2022, 3:20 PMdubo
10/03/2022, 5:03 PMchaos
10/03/2022, 6:21 PMVik
10/03/2022, 8:39 PMcreate table profiles (
id uuid references auth.users not null,
join_date timestamp with time zone,
username citext unique,
avatar_url text,
first_name text,
last_name text,
birthday text,
about text,
private boolean,
primary key (id),
constraint username_length check (char_length(username) >= 3 and char_length(username) <= 30),
constraint first_name_length check (char_length(first_name) <= 30),
constraint last_name_length check (char_length(last_name) <= 30),
constraint birthday_length check (char_length(birthday) <= 50),
constraint about_length check (char_length(about) <= 100)
);
As for the username, I left it just as unique because I want to handle that flow on the frontend. If the username is not set the user has not completed onboarding so they will be presented with a username creation screen first.
But for my function, I do want it to set the id, join_date, and private to false.
This is what I have written out but would love some eyes on it.
begin
insert into profiles(id, join_date, private)
values(new.id, new.now(), new.false)
end;
Does the new.now()
work as I expect it to? A date time stamp and in general does that function structure look correct?
Thank you in advance!user8923
10/04/2022, 2:42 AMany
type. What is the type of the payload
arg in the example below?
supabase
.channel("*")
.on("postgres_changes", { event: "*", schema: "*" }, payload =>
{
console.log("Change received!", payload);
})
.subscribe();
Homemadesteam58
10/04/2022, 6:02 AMAntonOfTheWoods
10/04/2022, 6:19 AMrinorzk
10/04/2022, 8:45 AMeq("type", "public")
, but I wanted to ask is this the safest way, is there a better way to secure this?lewisd
10/04/2022, 8:54 AMconversationMessages
table and filter by the conversationId
that we are currently on - Great stuff ✅
The problem I have is the Inbox component. It needs to show:
- All current conversations you're involved in
- The latest message sent to each chat
- Whether it has been read or not by the user (I compare conversationMembers.lastRead
with the latest conversationMessages.createdAt
- Needs to update in realtime - if im on my inbox screen and get a new message, I expect that chat to move up to 1st place and show the new message.
I have created a view
called conversationsView
that gets all the above data ready for me and it works great.
However, I failed to realise you cannot use realtime
on views
😔 so my plan has failed on the last hurdle. When a new message is sent, the inbox is not updated in realtime.
Does anyone see a way of achieving this? Im quite new to SQL.
I've attached an image of my db design and chat component.
I've spent 3 days trying to figure out a way of doing this 😆 If anyone has a good method of achieving this please put me out of my misery haha.caracalla
10/04/2022, 9:46 AMMidas
10/04/2022, 11:07 AMdanishyasin33
10/04/2022, 1:37 PM매튜
10/04/2022, 5:22 PMCorentin_dev
10/04/2022, 7:51 PMMilou
10/05/2022, 12:05 AMpg_jsonschema
extension installed. Since the pg_jsonschema
extension is not yet available in the default supabase/postrges images, I wan't to build a custom one locally.
According to this wiki page:
https://github.com/supabase/postgres/wiki/Docker
I am supposed to run this ansible playbook in order to generate a container:
https://github.com/supabase/postgres/blob/develop/ansible/playbook-docker.yml
This playbook imports, among other tasks, this task file:
https://github.com/supabase/postgres/blob/develop/ansible/tasks/docker/setup.yml
Which to me looks like tasks that should be run inside the container, correct? The docs don't mention that this playbook should be run against a running container, it sounds more like the container is generated when running the playbook.
Could someone clarify how this works?user8923
10/05/2022, 2:53 AM