The Problem
I have a simple next.js application. On the index site I have following code:
export async function getServerSideProps(ctx: NextPageContext) {
const json = await myGet("/api/people", ctx);
return {
props: {
people: json,
}, // will be passed to the page component as props
};
}
myGet
does just a simple fetch (with isomorphic fetch) to an api route with the url /api/people
. This however fails with this error:
Server Error TypeError: Only absolute URLs are supported
My expectation would be that I can use a path just like "/api/people" since I serve the app from the same base url. In next.js do I have to explicitly provide the full URL? (e.g. https://my-app/api/people)
Thx guys