-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Calling a test api from a RSC returns Error: Failed to parse URL from /api/test, as there is no http://localhost:3000 prefix in the fetch call from the server.
Example code in app/page.tsx:
import { getApitest } from "@/routes";
export default async function Home() {
const x = await getApitest() // error
return (
<main className="">
{x.message}
</main>
);
}
Example API in app/api/test/route.ts:
import { NextResponse } from "next/server";
export async function GET() {
return NextResponse.json({ message: "Hello, World!" });
}
Generated code in routes/index.ts:
export const getApitest = makeGetRoute(
"/api/test",
{
...defaultInfo,
...ApitestRoute.Route
},
ApitestRoute.GET
);
I guess createRouteBuilder function should understand when to return the env.NEXT_PUBLIC_URL for APIs, or just always return it
Metadata
Metadata
Assignees
Labels
No labels