wepsree
05/28/2023, 2:38 AMalana
05/28/2023, 3:30 AMhttps://cdn.discordapp.com/attachments/1112221280075264051/1112221280217866240/CleanShot202023-05-2720at2014.15.482x.jpg▾
ven
05/28/2023, 3:45 AMCREATE OR REPLACE FUNCTION set_claim() RETURNS TRIGGER AS $$
BEGIN
NEW.raw_app_meta_data = NEW.raw_app_meta_data || jsonb_build_object('role', 'USER');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
any thoughts on the pros/cons of the new rewrite. seems to get the job done.alpi
05/28/2023, 3:52 AMash
05/28/2023, 11:42 AMStorageApiError: The resource was not found
.
const { data, error } = await supabase.storage
.from("user-files")
.createSignedUploadUrl(filename);
supabase
is an instance of the Supabase client initialized with the service role key as follows...
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(supabase_url, service_role_key, {
auth: {
autoRefreshToken: false,
persistSession: false
}
})
Looking at the error logs for the Supabase Storage container running locally on Docker I see the following error...
DatabaseError: failed to retrieve bucket
at new DatabaseError (/app/dist/storage/errors.js:22:28)
at Database.<anonymous> (/app/dist/storage/database.js:105:35)
at step (/app/dist/storage/database.js:33:23)
at Object.next (/app/dist/storage/database.js:14:53)
at fulfilled (/app/dist/storage/database.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 406,
postgresError: {
code: 'PGRST116',
details: 'Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row',
hint: null,
message: 'JSON object requested, multiple (or no) rows returned'
},
metadata: { bucketId: 'upload' }
}
Weird because the list operation on the same bucket works fine, not sure why bucketId is "upload" in the metadata section above either.
Anybody have any ideas?salzar
05/28/2023, 12:07 PMonurhan1337
05/28/2023, 12:10 PMts
"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { Session } from "@supabase/supabase-js";
import { useRouter } from "next/navigation";
async function AddCommment() {
const supabase = createClientComponentClient();
const router = useRouter();
async function signInWithGitHub() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: "github",
});
}
const handleSignOut = async () => {
await supabase.auth.signOut();
router.refresh();
};
return (
<div className="mt-10">
<button
onClick={() => {
signInWithGitHub();
}}
>
Sign In
</button>
{/* if user logged in */}
<button onClick={handleSignOut}>Sign Out</button>
</div>
);
}
export default AddCommment;
elhe26
05/28/2023, 12:48 PMぴんく
05/28/2023, 1:21 PMSELECT
(they do not need to login)
* users will never write to the database
* there is a GCP Cloud Function that performs a DELETE
and INSERT
to my table
Given this setup, should I use the service_role
API key for my Cloud Function? Or would it make more sense to setup a custom role?
If the latter is the case, I suppose I would have to setup a policy that checks for a predefined email
field, and also handle refreshing the JWTs every once in a while.
I didn't really see a section for service accounts in the docs, so I wanted to know how other people would handle this setup. Thanks in advance 🙏.Volxen
05/28/2023, 2:38 PMZombi
05/28/2023, 2:54 PMhttps://cdn.discordapp.com/attachments/1112393401262944317/1112393401405546526/image.png▾
Kwinn
05/28/2023, 3:14 PMconst queryCC = async (query) => {
try {
let { data, error } = await supabase
.from('cc')
.select(`*, champions ( id, name ), roles ( id, role )`)
.gte("currentrank", query.rank ? query.rank.id : 1)
.contains("champions", [query.champion.id])
;
cc = data;
} catch (err) {
console.log(err);
}
};
I have the tables "cc", "champions", "roles", "championRelations", "roleRelations". I want to get all the rows where "championsRelations" contains the specified champion. How do I do that? My .contains doesn't seem to work.ven
05/28/2023, 3:56 PMrunning migrations
(node:1) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
(Use `node --trace-warnings ...` to show where the warning was created)
finished migrations
supabase_pg_meta_projectjuniper container logs:
> @supabase/postgres-meta@0.0.0-automated start
> node dist/server/server.js
(node:52) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
supabase_studio_projectjuniper container logs:
info - Loaded env from /app/studio/.env
Listening on port 3000
Error: service not healthy: [realtime-dev.supabase_realtime_projectjuniper supabase_storage_projectjuniper supabase_pg_meta_projectjuniper supabase_studio_projectjuniper]
Kwinn
05/28/2023, 3:58 PMconst queryCC = async (query) => {
try {
let { data, error } = await supabase
.from('cc')
.select(`*, champions!inner ( id, name ), roles!inner ( id, role )`)
.gte("currentrank", query.rank ? query.rank.id : 1)
.eq("champions.id", query.champion.id)
.eq("roles.id", query.role.id)
;
cc = data;
} catch (err) {
console.log(err);
}
};
As you can see in the ".gte" line sometimes my values are equal to null and in that special case I can assign a default value. But with the two ".eq" lines I'd rather check for if query.role/query.champion are null and when they are just exclude the entire ".eq" statement. How can I do that?formigueiro
05/28/2023, 4:00 PMhttps://my project.supabase.co/auth/v1/verify?token=token&type=recovery&redirect_to=http://localhost:3000/update-password/email
but after user clicks in this link
if you already have another tab of the application open, it is already logging in, even before I update the password.;WavyTaikage
05/28/2023, 4:25 PMhttps://cdn.discordapp.com/attachments/1112416372429955142/1112416372740337825/cookie_error.png▾
https://cdn.discordapp.com/attachments/1112416372429955142/1112416373088456764/login_code.png▾
https://cdn.discordapp.com/attachments/1112416372429955142/1112416373516279969/register_code.png▾
Stephcraft
05/28/2023, 7:38 PMphil
05/28/2023, 7:57 PMlennard.
05/28/2023, 9:15 PMjs
const mp3 = event.target.files[0]
const { data, error } = await supabase
.storage
.from('audios')
.upload('audio.mp3', mp3, {
cacheControl: '3600',
upsert: false
})
I want to upload a file, but how do I generate the filename (here represented as "audio.mp3" to be a UUID or something auto generated?jcurbelo
05/28/2023, 9:17 PMgetRootDomain
function to return the root domain from a URL, like foo.bar.com
gives us bar.com
. It's also localhost-friendly.
In our app, we're using Supabase and trying to dynamically set the cookie domain using getRootDomain
. Here's how we're doing it in our _app.tsx
file:
tsx
const [supabase] = React.useState(() =>
createBrowserSupabaseClient({
cookieOptions: {
domain:
typeof window !== 'undefined'
? getRootDomain(window.location.href)
: undefined,
maxAge: 60 * 60 * 24 * 10, // 10 days
path: '/',
sameSite: 'Lax',
secure: true,
},
})
);
For the server side, we're whipping up the Supabase client with `createServerSupabaseClientWithCookies`:
tsx
export const createServerSupabaseClientWithCookies = (
ctx: GetServerSidePropsContext
) =>
createServerSupabaseClient(ctx, {
cookieOptions: {
domain: getRootDomain(ctx.req.headers.host || ''),
maxAge: 60 * 60 * 24 * 10, // 10 days
path: '/',
sameSite: 'Lax',
secure: true,
},
});
We've got an auth middleware set up too, but despite all this, we can't seem to get the cookie to set right. And this isn't just a production problem - it's happening locally too.
We've been through a bunch of GitHub discussions, like this one: https://github.com/orgs/supabase/discussions/5742 but no luck Any advice on this topic?Revaycolizer
05/28/2023, 9:28 PMlennard.
05/28/2023, 9:36 PMjs
import { supabase } from "./supabase";
export async function uploadFile(audioFile) {
const { uploadData, uploadError } = await supabase
.storage
.from('audios')
.upload('audio.mp3', audioFile, {
cacheControl: '3600',
upsert: false
}
)
console.log({uploadData, uploadError})
if (uploadError) {
return uploadError.message;
}
const { publicUrl } = supabase
.storage
.from('audios')
.getPublicUrl(uploadData.path)
return publicUrl;
}
But when running it the console and returns only give a undefined. Why?rykuno
05/28/2023, 9:40 PMlocally
i get an error of {"code":400,"msg":"PKCE flow is not supported on signups with autoconfirm enabled"}
when signing up.
Reading the docs, I'm unsure of what exactly the issue is :(.HG_SHGYT
05/28/2023, 9:55 PMbombillazo
05/28/2023, 10:55 PMsupabase.auth.signInWithPassword
to sign in, and the JWT for auth purposes, but how can I keep the user logged in until they are inactive X amount of time from their last request to the server?skofff
05/28/2023, 11:34 PMTrashPanda
05/29/2023, 1:04 AMcreated_at
. I want to avoid adding more logic to client, so I hope to avoid asking every client to not include created_at
value when sending the payload.moarwick
05/29/2023, 3:31 AM.order('keyName', { foreignTable: 'tableName', ascending: false })
but that doesn't appear to translate to graphql. The generated ...OrderBy
type seems to imply only origin table attributes can be used for the sort key. Anyone got it to work, have an example? 🙏huiwang
05/29/2023, 3:31 AMEsore
05/29/2023, 3:47 AMhttps://cdn.discordapp.com/attachments/1112587888962576535/1112587889172299836/image.png▾