Fayyaz
03/06/2023, 1:07 PMVimes
03/06/2023, 1:13 PMtom-s3drive
03/06/2023, 1:47 PMBiondi Bagasta Wiko Putra
03/06/2023, 1:51 PMAdamJensen
03/06/2023, 1:58 PMAbku
03/06/2023, 2:11 PMOskarsh
03/06/2023, 2:16 PMVal
03/06/2023, 3:09 PMhomyak
03/06/2023, 3:38 PMimport { createClient } from '@/utils/supabase-server
into an api route I am receiving the error below, but when I use supabase-browser
I do not get any errors. If the API routes are always executed on the Nextjs server, why should I have to use the supabase browser client provided by createBrowserSupabaseClient
? I am attempting to register a user within an API route in order to perform other user initialization tasks upon user creation, rather than calling signUp
from within a client component.
// api/register/route.js
import { createClient } from '@/utils/supabase-server' // Error in terminal
export async function POST (request) {
const supabase = createClient()
const { data, error } = await supabase.auth.signUp({
email: 'example@example.com',
password: 'password',
})
return Response.json(data)
}
bash
Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
./node_modules/@supabase/supabase-js/dist/main/index.js
./node_modules/@supabase/auth-helpers-shared/dist/index.js
./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
./utils/supabase-server.js
./app/layout.js
./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/homyak/development/personal/authentication-template-supabase/node_modules/node-fetch/lib'
Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
./node_modules/@supabase/supabase-js/dist/main/index.js
./node_modules/@supabase/auth-helpers-shared/dist/index.js
./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
./utils/supabase-browser.js
./components/login-button.jsx
Madses
03/06/2023, 3:59 PMstevecaldwell
03/06/2023, 4:00 PMbrassotron
03/06/2023, 4:58 PMteams
and team_members
.
The teams table only has a name
column and team_members has only team_id
and user_id
columns.
Teams has an insert RLS policy that allows any authenticated user to insert a team with a given name. A trigger is then executed AFTER INSERT on teams and will insert a row into team_members with the id
of the inserted team (team_id
) and the current auth.uid() (user_id
);
If I add an RLS policy to the teams table to only allow SELECT on teams you're a member of;
sql
exists (
select * from team_members where team_members.team_id = teams.id and team_members.user_id = auth.uid()
)
This fails with the following JavaScript snippet due to an RLS failure for teams.
ts
const { error, data } = await supabase.from('teams').insert({ name }).select('*');
However, if I use the following JavaScript instead, it works as expected.
ts
const { error } = await supabase.from('teams').insert({ name });
const { error, data } = await supabase.from('teams').select('*');
console.log(data) // contains the created team
I expect this is due to the order of operation that the RLS policy is evaluated and the trigger executes? In that in the first snippet at the point the select is executed the trigger has yet to insert the team_member
row and therefore fails?
Thanks for any help!
ConnorCOLD1
03/06/2023, 5:09 PMleif
03/06/2023, 5:29 PMenti
03/06/2023, 5:38 PMid
column, which is an Auto Increment Primary Key. I want to upsert
many values at once, with somes existing, somes not.
json
[
{
"id": 611,
"answer": "answerOld",
}, {
"answer": "answerNew",
}
]
The upsert
API call gives me this response : "All object keys must match"
id
not being provided for the new entry while it is for the old entries seems to be a problem for some reasons.
The postgres doc offers a DEFAULT
keyword which can't apply in javascript. I can't find a way to specify a default incremental value for id
through an API call around the supabase doc.
How could I resolve that problem without making 2 API calls, which wouldn't really be the best option?chrtravels
03/06/2023, 5:46 PMconst avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('bucketName')
.upload('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
The problem is, the URL, for images stored in this bucket look like:
/storage/v1/object/**public/banner-images**/test.png
but using the function above you get:
/storage/v1/object/**banner-images/public**/test.png
So "public" should come before the bucket name.
It's possible the URL to post images in the bucket should be different but we don't actually know what it should look like since this is all done through these supabase functions.just9inches
03/06/2023, 5:55 PMnateland
03/06/2023, 6:00 PMmjs
03/06/2023, 6:15 PMkevlust
03/06/2023, 6:57 PMchrtravels
03/06/2023, 7:11 PMBizzare
03/06/2023, 7:28 PMstructure:
{
"color": {
"value": "red"
},
"dimension": {
"value": "100x100"
}
}
I want to be able to delete the whole key "color" for example. If I'm doing the following:
`async delete_characteristic(name, row_id) {
const { data, error } = await supabase.from('table_name')
.delete()
.eq('characteristic_id', row_id)
.eq(characteristics->${name}
, name)
.select();
}`
I get an error with message: 'invalid input syntax for type json' for the "name".
I ended up extracting the whole column value and updating it after performing a delete(name) on the JS object, but I was wondering if I can achive the same with supabase.from().delete().
Thank you!goldyman
03/06/2023, 9:17 PMdart
final map = gift.toJson();
final userId = _supabaseClient.auth.currentUser!.id;
final result = await _supabaseClient.from('gifts').insert({
'description': gift.description,
'owner': userId,
'latitude': gift.latitude,
'longitude': gift.longitude,
'colors': map['colors']
}).select<Map<String, dynamic>>(
'''
*,
users(id, email, username, birthday, created_at, hasAvatar),
tags(*)
''',
);
I the specific case I don't have any tags attached yet. the insert request is later in the flow. Is it possible that it is throwing because there are not tags yet?Hallidayo
03/06/2023, 9:21 PMhko
03/06/2023, 9:24 PMyayza_
03/06/2023, 9:26 PMno filters for this update query
I was wondering what that meansDYELbrah
03/06/2023, 9:38 PMCREATE PROCEDURE saveTransactionSP(
IN transaction_id INTEGER,
IN transaction_line_items TRANSACTION_LINE_ITEM_IN[],
IN full_length_stock_picks FULL_LENGTH_STOCK_PICK_IN[],
.....
I then generated my supabase types and noticed that the procedure isn't anywhere on the generated types.tincan
03/06/2023, 9:45 PMzachblume
03/06/2023, 10:09 PMrobertn702
03/06/2023, 10:10 PMAuthApiError: Token has expired or is invalid
error). I assume this is due to changes made in @supabase/gotrue
.
Does anyone know if there is a similar workaround? I have tried manually setting the recovery_token
, reauthentication_token
, and their respective sent_at
values, with no luck.
[0]: https://github.com/supabase/supabase/discussions/5358#discussioncomment-4704569