I am running through an error while trying to deploy the app to Vercel. The issue mainly happens when trying to run next build because it is working fine on my localhost:3000. This is package.json
{
"name": "foodrecipe",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@contentful/rich-text-react-renderer": "^15.4.0",
"contentful": "^9.0.3",
"next": "11.1.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"eslint": "7.32.0",
"eslint-config-next": "11.1.2"
}
}
This is the complete log:
These are getStaticPaths/props functions in [slug].js:
const client = createClient({
space: process.env.CONTENTFUL_SPACE_ID ,
accessToken:process.env.CONTENTFUL_ACCESS_KEY
})
export const getStaticPaths = async()=>{
const response = await client.getEntries({content_type:'recipesReactjs'})
const paths = response.items.map(item =>{
return{
params:{slug: item.fields.slug}
}
})
return{
paths:paths,
fallback:true,
}
}
export const getStaticProps = async(context)=>{
const response = await client.getEntries({
content_type:'recipesReactjs',
'fields.slug':context.params.slug,
})
if(!response.items.length){
return{
redirect:{
destination:'/',
permanant:false
}
}
}
return{
props:{myRecipe: response.items[0]},
revalidate:1 ,
}
}