I have used the below code. It is working with npm run dev. But while doing the npm run build it is getting failed due the network failed error:
export async function getStaticProps({ params }) {
let skuId = params.sku;
const res = await axios.get(`http://localhost:3001/api/get/product/${skuId}`);
const data = await res.data;
return {
props: {
post: data
}
}
}