Nextjs ssr data fetching
See original GitHub issueBug report
Describe the bug
Hello. I’m trying to fetch data using match filter. But sometimes it works and sometimes it doesn’t work. It errors out even though i gave it the right parameter. Response: message: ‘invalid input syntax for type uuid: “”’, code: “22P02”.
To Reproduce
Code:
export const getServerSideProps: GetServerSideProps<UserPageProps> = async (
context
) => {
const params = context.params; // params.username
const client = supabase;
const res = await client
.from<definitions["profiles"]>("profiles")
.select(`id, username, avatar_url, display_name, bio`)
.eq("username", params!.username as string)
.single();
if (res.data) {
console.log(res.data.id);
const articlesRes = await client
.from<definitions["posts"]>("posts")
.select(
`
*,
tags!post_tag (*),
user:user_id (*)
`,
{ count: "estimated" }
)
.match({
user_id: res.data.id,
published: true,
post_type: "article",
})
.range(0, 23)
.order("created_at", { ascending: false });
console.log(articlesRes);
return {
props: {
profile: res.data,
articles: {
articles: (articlesRes.data as PostsJoins[]) ?? [],
count: articlesRes.count ?? 0,
},
},
};
}
return {
notFound: true,
};
};
Failed response:
10aa457d-5c2c-4e7b-b5de-eb6f63589a2f <- user_id
{
error: {
message: 'invalid input syntax for type uuid: ""',
code: '22P02',
hint: null,
details: null
},
data: null,
count: null,
status: 400,
statusText: 'Bad Request',
body: null
}
Expected behavior
To fetch data properly
System information
- OS: macOS
- Browser (if applies) Firefox
- Version of @supabase/supabase-js: 1.28.4
- Version of Next: 12.0.3
- Version of React: 17.0.2
Additional context
Add any other context about the problem here. It works completely fine on client side. And also the tables have public read access.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Data Fetching: Overview - Next.js
Next.js allows you to fetch data in multiple ways, with pre-rendering, server-side rendering or static-site generation, and incremental static regeneration.
Read more >Data Fetching: getServerSideProps - Next.js
Fetch data on each request with `getServerSideProps`. ... Caching with Server-Side Rendering (SSR). You can use caching headers ( Cache-Control ) inside ...
Read more >Client-side data fetching - Next.js
The team behind Next.js has created a React hook library for data fetching called SWR. It is highly recommended if you are fetching...
Read more >Pre-rendering and Data Fetching | Learn Next.js
In this lesson, we'll learn how to fetch external blog data into our app. We'll store the blog content in the file system,...
Read more >Fetching Data at Request Time - Pre-rendering and ... - Next.js
The data is frequently updated, which requires request-time data fetching. SWR. The team behind Next.js has created a React hook for data fetching...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @mtergel I noticed this seems pretty much like the issue I was facing at https://github.com/supabase/supabase/issues/4244. The fix there might be helpful to you!
Edit: This is probably relevant only if you have RLS policies comparing a UUID with
auth.uid()
.thanks for this @bnjmnt4n 🙏