stukennedy
11/11/2022, 4:47 PMgetSupabase
method for the backend that retrieves the JWT from the cookie and sets the session using supabase.auth.setSesssion(...)
That all works nicely and I can call the api etc.
Problem is when I try to logout.
I've tried a bunch of things.
I delete the cookies and try to call setSession
and refreshSession
(which shouldn't work as it has no tokens to work on anymore from the cookies) but it still returns a user until I manually refresh the page again.
What am I doing wrong?Revaycolizer
11/12/2022, 9:36 AMHermes
11/12/2022, 2:26 PMremoveChannel()
which unsubs and 'removes' the channel from client.
What does the remove part mean, if multiple clients are connected to the channel, and one client does a removeChannel()
with that channels' name, does it also end the channel for the other clients?
And there is also a supabase.channel().unsubscribe()
which 'unsubscribes from server events and instructs server to terminate'...
JavaScript
// snippet from CommentItem component
// LISTEN FOR WHEN THE COMMENT IS UPDATED OR DELETED
useEffect(() => {
const { id: commentID } = commentData;
const channelName = `public:comments:id=eq.${commentID}`;
supabase
.channel(channelName)
.on(
"postgres_changes",
{
event: "UPDATE",
schema: "public",
table: "comments",
filter: `id=eq.${commentID}`,
},
onCommentUpdated
)
.on(
"postgres_changes",
{
event: "DELETE",
schema: "public",
table: "comments",
filter: `id=eq.${commentID}`,
},
onCommentDeleted
)
.subscribe();
return () => supabase.removeChannel(channelName);
}, [commentData, onCommentDeleted, onCommentUpdated]);
I just want that when the commentItem component unmounts, it should stop listening for those postgres changes on the comments table.Spoonz
11/12/2022, 7:23 PMError: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
Abhinav_MV
11/12/2022, 7:32 PMSpoonz
11/12/2022, 8:25 PM@supabase/auth-helpers-react
and @supabase/auth-helpers-nextjs
packages. Every time I try and get it to work myself I end up with useContext errors as the useSupabaseClient() hook is being called outside of the main function.jkohlin
11/12/2022, 11:46 PMdonnybystrom
11/13/2022, 9:40 AMError: ERROR: relation "graphql.schema_version" does not exist (SQLSTATE 42P01)
At statement 125:
--
-- Name: TABLE "schema_version"; Type: ACL; Schema: graphql; Owner: supabase_admin
--
GRANT ALL ON TABLE "graphql"."schema_version" TO "postgres";
Looking at the generated migration file, it doesn't seem to create the table graphql.schema_version.
I'm guessing the CLI creates a different type of base database locally than what is hosted remotely? The remote project is 4-5 months old and been done entirely in production.
Do you guys know what I can do? Is there a better way to migrate the db, a way to ensure local is the same version as remote, or a safe way to upgrade the remote db?
My supabase CLI version is 1.12.2
Best regards
Donnysebx
11/13/2022, 10:14 AMsebx
11/13/2022, 11:11 AMts
const {data} = await supabaseClient.from("subscriptions")
.update({...subscriptionData}) // includes {"isSubscribed": true}
.match({subscriberId: sub.userId})
.select('subscriberId,isSubscribed')
console.log(data)
// {"subscriberId": 4926568, "isSubscribed": true}
BUT sql editor on dashboard returns isSubscribed: false
I also tried using prisma, same problem. Doesn't save the updates....chrismasters
11/13/2022, 12:38 PMsql
CREATE TABLE public.playlists (
id bigint generated by default as identity primary key,
track_id bigint references public.tracks NOT NULL
);
CREATE TABLE public.tracks (
id bigint generated by default as identity primary key,
title text NOT NULL,
artist_name text
);
And then access this with a query like this...
ts
const { data } = await supabase
.from('playlists')
.select(`
id,
tracks (
title,
artist_name
)
`)
I'd imagined that tracks.title
could only be either a string
or null
type so I could use tracks?.title
to make Typescript happy.
But my typescript is giving errors if I use either tracks.title
or tracks?.title
ts
Property 'title' does not exist on type '({ title: string; } & { artist_name: string | null; }) | ({ title: string; } & { artist_name: string | null; })[]'.
Property 'title' does not exist on type '({ title: string; } & { artist_name: string | null; })[]'.
What am I missing?
Also, semantically, shouldn't this relationship name be better changed to track
from tracks
as it is singular?
Thanks!MrSandyWilly
11/13/2022, 3:56 PMSELECT * FROM textures ORDER BY id DESC LIMIT 1;
Trying to select the most recent row.Mx
11/13/2022, 7:34 PMdonnybystrom
11/14/2022, 8:40 AMMDobs
11/14/2022, 2:33 PMUPDATE
for changes in a DB row using realtime, however the response I get on the new
property of the payload doesn't include all the data from that row.
Specifically querying the db row does bring back the complete dataset as expected.
Is this correct behavior?hyodo
11/14/2022, 4:06 PMkonga
11/15/2022, 12:06 AMjor
11/15/2022, 4:41 AMKellen Mace
11/15/2022, 5:40 AMts
const userSession = (await supabase.auth.getSession()).data.session;
const response = await fetch('/api/stripe-checkout-session', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
accessToken: userSession?.access_token ?? '',
refreshToken: userSession?.refresh_token ?? '',
})
});
The request handler function for that API endpoint looks like this:
ts
export async function POST(event: RequestEvent): Promise<Response> {
const { accessToken, refreshToken } = await event.request.json();
const { data: setSessionData, error: setSessionError } = await supabase.auth.setSession({
access_token: accessToken,
refresh_token: refreshToken,
});
// 👇 Results in `{ session: null }`
const { data: getSessionData, error: getSessionError } = await supabase.auth.getSession();
}
When I run console.log(setSessionData)
, I get this:
ts
{
session: {
access_token: 'access-token-goes-here',
refresh_token: 'refresh-token-goes-here',
user: { ... },
token_type: 'bearer',
expires_in: 2402.638000011444,
expires_at: 1668490476
},
user: {
id: 'user-id-goes-here',
aud: 'authenticated',
role: 'authenticated',
// ...
}
}
Zeph
11/15/2022, 8:53 AMts
import { Auth, ThemeSupa } from '@supabase/auth-ui-react'
import { useSupabaseClient } from '@supabase/auth-helpers-react'
export default function Login() {
const supabaseClient = useSupabaseClient()
return (
<Auth
supabaseClient={supabaseClient}
appeararance={{ theme: ThemeSupa }}
theme="dark"
socialLayout='horizontal'
redirectTo="http://localhost:3000/"
/>
)
}
But my UI ends up looking like the image attached.
Also, the redirect does not work. I am still able to login and logout but its just the styling and redirect that is the issue.
Thank you!49Ryann
11/15/2022, 10:38 AMhttps://.....supabase.co/auth/v1/verify?token=cbf72dec7017df95f6e91762124ef76943a367eb441af09c9e8f4f1e&type=recovery&redirect_to=http://localhost:4200/
Diogovski
11/15/2022, 5:59 PMSmardrengr
11/15/2022, 7:01 PM500
error when Supabase tries to apply auth actions.
Unexpected token 'I', "Invalid request body" is not valid JSON
SyntaxError: Unexpected token 'I', "Invalid request body" is not valid JSON
?! Only a few minor changes to the project from what I pushed to production yesterday (and which works). Cannot for the life of me see what suddenly changed. This error happens in npm run dev
and npm run build
. Here's the DevTools window:
Any ideas? Where should I look?iStun4Fun
11/15/2022, 8:34 PMCardoso
11/16/2022, 1:55 AMCREATE OR REPLACE FUNCTION close_advertisements (lat float, lng float)
RETURNS SETOF public.advertisements
LANGUAGE plpgsql
AS $$
BEGIN
RETURN query (
SELECT
*
FROM
advertisements
WHERE
ST_DWithin (geom, ST_SetSRID (ST_MakePoint (lng, lat), 4326), 10000));
END;
$$
SECURITY DEFINER SET search_path = extensions, public, pg_temp;
Error message:
"Could not find the public.close_advertisements() function or the public.close_advertisements function with a single unnamed json or jsonb parameter in the schema cache"
I added the security definer to try an make it visible but without successdave johnson
11/16/2022, 2:04 AMDavepar
11/16/2022, 2:12 AMimport { createClient } from '@supabase/supabase-js'
const PUBLIC_SUPABASE_URL="https://xxxxxxxxx.supabase.co";
const PUBLIC_SUPABASE_ANON_KEY="xxxxxxxxxxxxx";
const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY);
const result = await supabase.auth.signInWithPassword({
email: 'bob@example.com',
password: 'mypassword',
});
console.log('result', result);
console.log('user', await supabase.auth.getUser());
The signInWithPassword() call returns the correct session and user, but the getUser() call returns the error:
AuthApiError: invalid claim: missing sub claim
And any other call seems to be unauthenticated.darren
11/16/2022, 2:19 AMcreateClient(URL, KEY, {db: {schema: 'stats'}} )
as seen in the reference guide for supabase-js [1].
The error I get when I run this locally is: error: TS2322 [ERROR]: Type '"stats"' is not assignable to type '"public"'
. I have verified that this schema does exist in the local database when I run psql directly.
According to the docs, you have to expose new schemas to the API via the supabase dashboard by going to Settings > API Settings > Exposed Schemas
and adding it manually there. Unfortunately, while this works for the production dashboard I can't get to that setting on my local dashboard.
What can I do to expose a schema I made on local?
[1]: https://supabase.com/docs/reference/javascript/initializing#api-schemasarch
11/16/2022, 8:35 AMSiddharth
11/16/2022, 9:28 AM