I am creating a Trello-like application using Next.js and Supabase as my backend as a service.
Within my Supabase table, I have set up certain policies:
https://i.sstatic.net/gl5Si.png
The policies function correctly on the client-side with this code snippet:
const { data } = await supabase
.from<BoardType>('board')
.select('*')
.eq('id', board.id)
.single();
However, when attempting to retrieve board information in getServerSideProps
, it consistently returns null. I know that for accessing the authenticated user on the server-side, you must use
supabase.auth.api.getUserByCookie(context.req)
. So, I am unsure if there is something I am overlooking, as I couldn't find any relevant information regarding this issue.
Does anyone have experience dealing with this scenario?
[Edited]
Below is the code within the getServerSideProps
:
export const getServerSideProps: GetServerSideProps<BoardSlugProps> = async ({
query,
}) => {
const { data } = await supabase
.from<BoardType>('board')
.select('*')
.eq('id', query.slug as string)
.single();
console.log(data);
return {
props: {
board: data,
},
};
};