fxs
03/05/2023, 5:01 PMsql
CREATE OR REPLACE FUNCTION rls_check(origin text)
RETURNS boolean AS $$
BEGIN
RETURN origin = 'https://******.netlify.app';
END;
$$ LANGUAGE plpgsql;
a function that should return true or false, where the asterisks are my site name, everything is correct there, I took it from the header of the request.
sql
CREATE POLICY my_table_policy ON my_table
FOR ALL
TO my_user
USING (rls_check(current_setting('request.headers.origin')) = true);
this rule in RLS as, I don't really understand sql, but I think that everything is correct here too.
I added this code, tried different options, wrote manually, through sql editor nothing helps, I get a 404 error when sending or receiving a request.
I think it's the function itself, because when I wrote RETURN true
everything worked.
What am I doing wrong? What could be wrong? What other solutions do you know?
Thank you.Chris.
03/05/2023, 5:01 PMauth().getUser()
i receive this error.ItsAmir
03/05/2023, 5:52 PMtom-s3drive
03/05/2023, 5:53 PMonAuthStateChange
during password change not getting SIGNED_IN
or PASSWORD_RECOVERY
events. (https://github.com/supabase/supabase/discussions/3360#discussioncomment-3947228)
2. When requesting signUp:
final res = await supabase.auth.signUp(email: email, password: password, emailRedirectTo:
kIsWeb ? null : 'com.app.scheme://login-callback/');
The: emailRedirectTo
option seem to be ignored (and default redirectTo option is used in URL instead), despite it being added to whitelist: https://app.supabase.com/project/projectId/auth/url-configuration in Redirect URLs section.
3. How to handle user requesting password change on their phone, but clicking link on a different device, e.g. desktop. Currently account is confirmed, but because: onAuthStateChange
doesn't seem to be working, I can't notify user about account being somewhat ready... and if redirection issue mentioned in 2. is fixed, then link would be technically incorrect on desktop anyway.
One of the options would be to disallow user accepting an e-mail without valid session, but I wasn't sure if such config option is possible.
What's the recommended way?
I am sure it's mostly me being the issue and please don't take it as a complaint. Project is great, it's just I am struggling to build robust basic workflow.
Any hints appreciated.Aless.c06
03/05/2023, 6:20 PMkwhuo68
03/05/2023, 6:27 PMroom_id=eq.${roomId}
},
(payload: any) => {
console.log('Watching postgres changes: ', payload);
}
) ...`
and a function for updating messages:
// Get character message to user
export async function getNextMessage(
roomId: number,
...
) {
...
const nextMsgId = (await getLatestMsgId(client)) + 1;
const new_msg = {
id: nextMsgId,
room_id: roomId,
recipient_id: userId,
sender_id: senderId,
message,
};
const res = await client.from('messages_character_to_user').insert(new_msg);
}
Am just trying to run a basic proof of concept script involving these two locally, I am starting up the channel then running the message insertion, it seems like the rows are being added to Postgres DB but am not observing the console.log('Watching postgres changes: ', payload);
going through, is this expected / what changes would you recommend for testing out realtime functionality locally, for a message-based chat app? Thanks!chrtravels
03/05/2023, 6:29 PMJackBiscuits
03/05/2023, 6:39 PMjeffarizona93
03/05/2023, 7:08 PMmisakss
03/05/2023, 7:54 PMconst { data: { user } } = await supabase.auth.getUser()
user is null, even though I'm logged in. I'd appreciate any guidance on what I'm doing wrong.
My code (pages/api/userId.js):
import supabase from '../../lib/supabase-browser';
export default async function handler(req, res) {
const { data: { user } } = await supabase.auth.getUser()
if (user) {
res.setHeader('Access-Control-Allow-Origin', '*');
const userId = user.id; // retrieve the userId from Supabase
res.status(200).json({ userId });
} else {
res.status(401).json({ error: 'User not authenticated' });
}
}
PavolG
03/05/2023, 8:28 PMconfirmation_text
for magic_link
( it's currently Check your email for the magic link
, would love to be able to translate it as well to my language), or if it's planned any time soon?
Thanks a lot,
Pavolalb0z32
03/05/2023, 8:42 PMRake
03/05/2023, 11:23 PMts
const { supabase, session } = useSupabase()
Amara
03/06/2023, 12:05 AM1nf
03/06/2023, 12:46 AMTypeError: __vite_ssr_import_0__.createClient is not a function
at /src/lib/supabaseClient.js:4:24
at async instantiateModule (file:///home/ev/courvix/pay/node_modules/vite/dist/node/chunks/dep-ca21228b.js:52420:9)
ostoto
03/06/2023, 1:38 AMJY
03/06/2023, 3:31 AM'use client'
import { createContext, useContext, useState } from 'react'
import { createClient } from '../utils/supabase-browser'
const Context = createContext()
export default function SupabaseProvider({ children }) {
const [supabase] = useState(() => createClient())
useEffect(() => {
const { data: { subscription } } = supabase.auth.onAuthStateChange((event, session) => {
if (session?.access_token !== accessToken) {
router.refresh()
}
})
return () => subscription.unsubscribe()
}, [accessToken])
return (
<Context.Provider value={{ supabase }}>
<>{children}</>
</Context.Provider>
)
}
export const useSupabase = () => useContext(Context)
squallsama
03/06/2023, 3:42 AMselect net.http_get('https://news.ycombinator.com') as request_id;
I just got - SSL peer certificate or SSH remote key was not OK
- Could somebody point me where should I look ?
I'm using self-hosted supabase via docker compose with configured nginx as a revers proxy.zcomet
03/06/2023, 6:11 AMtimwis
03/06/2023, 8:22 AMawait supabaseClient.from('job_definitions')
.select(`
id,
user:user_id(email),
connection:connection_id(decrypted_access_token)
`).lt('last_synced_at', midnight)
kreferlink
03/06/2023, 8:52 AMmintho
03/06/2023, 8:57 AMyannxaver
03/06/2023, 10:32 AM/foo
which always fetches the same data from supabase - no matter if the visitor is logged in or not.
The problem: Because I use supabaseServerClient().auth.getSession()
in the root layout.tsx
the /foo
route becomes dynamic - so the data gets unnecessarily re-fetched on every visit.
To my understanding the new Next.js cache solves this problem by allowing me to cache the specific fetch in the /foo
route while keeping the route dynamic. How can I pass the desired cache behavior to the server component supabase client?viktor
03/06/2023, 10:40 AMcryptoneur
03/06/2023, 10:58 AMusernames
to the provider.
E.g. ideally there'd be a username
profile
object that contains more info about the logged in user, instead of having to rewrite client side queries.
How would I add this to the provider code below. Would love to see some examples 🙏
'use client'
import type { Session } from '@supabase/auth-helpers-nextjs'
import { createContext, useContext, useState } from 'react'
import type { TypedSupabaseClient } from '../app/layout'
import { createBrowserClient } from '../utils/supabase-browser'
type MaybeSession = Session | null
type SupabaseContext = {
supabase: TypedSupabaseClient
session: MaybeSession
}
// @ts-ignore
const Context = createContext<SupabaseContext>()
export default function SupabaseProvider({
children,
session,
}: {
children: React.ReactNode
session: MaybeSession
}) {
const [supabase] = useState(() => createBrowserClient())
return (
<Context.Provider value={{ supabase, session }}>
<>{children}</>
</Context.Provider>
)
}
export const useSupabase = () => useContext(Context)
jinsley8
03/06/2023, 11:08 AMhttp
extension to make a POST request to an API route on Vercel.
The error says
Operation timed out after 5001 milliseconds with 0 bytes received
Is this a limit on the free plan? Or is there something else that could be happening here?byod
03/06/2023, 11:17 AMtechleed
03/06/2023, 12:22 PMchrtravels
03/06/2023, 12:32 PMconst { data } = supabase
.storage
.from('public-bucket')
.getPublicUrl('avatars/myAvatar.png')
However when I try and access this image, I get resource not found. Any ideas?
I am using the default policy for the Avatars folder: Avatar images are publicly accessible.CauaLW
03/06/2023, 1:00 PM