I have a question about a project deployment with NextJS/Vercel.
According to documentation, await fetch
is supporting only absolute URLs. Example:
export async function getStaticProps(context) {
const route = process.env.APIpath + 'api/category/getCategories';
const res = await fetch(route)
const json = await res.json()
return {
props: {
data: json,
},
};
}
where APIpath: 'http://localhost:3000/',
Question: How can I deploy a project on vercel.com/test/my_project
? because when I only change process.env.APIpath
to vercel.com/test/my_project
= error.
P.S. Error message
Build error occurred
Error: Export encountered errors on following paths:
categories/database/categoryList - the page I am calling getStaticProps(context)
above