Api route returns Fetch Failed
Hey, I have an api route that returns some posts, it works when I navigate to it, but when I try to request it using a RSC, it throws a Fetch Failed error, export
async function getNews() {
const res = await fetch(`${env.NEXT_PUBLIC_APP_URL}/api/news`);
if (!res.ok) {
throw new Error("Failed to fetch data");
}
return res.json();
}export async function GET(req: Request) {
const allPosts: Post[] = await db.select().from(posts);
return NextResponse.json(allPosts, { status: 200 });
}export default async function News() {
const news: Post[] = await getNews();
console.log(news);
return (
<div>
<h1>News</h1>
</div>
);
}