Page is not being rendered when using getServerSideProps().
Unanswered
Tomistoma posted this in #help-forum
TomistomaOP
In my next 12.3.1, I am using
getServerSideProps() to get the data from strapi backend. On local machine all data are comming and I am able to see the page as well. But after deploying in vercel and setting up the environment I am not seeing any pages. All page routes returns code: 500 error. Before using server side props I was using getInitialProps() but here when I set the revalidation to be 5 and after updating the content from CMS same old data was being rendred even after days.1 Reply
TomistomaOP
import LandingPage from '@container/landingPage/landing'
import { baseUrl } from '@config'
import WebsiteUserLayout from '@layouts/websitesUser/WebsiteUserLayout'
export const getServerSideProps = async () => {
try {
const res = await fetch(`${baseUrl}/home-page`)
const global = await fetch(`${baseUrl}/global`)
const data = await res.json()
const globalData = await global.json()
return {
props: {
homePage: data,
globalData
}
}
} catch (error) {
console.log(error)
return {
props: { noConnection: true }
}
}
}
export default function home({ homePage, globalData, noConnection }) {
if (noConnection) {
return (
<>
<div className='flex h-screen w-full items-center justify-center'>
No Internet
</div>
</>
)
}
return (
<WebsiteUserLayout
documentTitle='Tessellate'
menu={globalData?.menu}
footer={globalData?.footer}
logo={globalData?.logo}
data={globalData}
others={globalData?.header}
>
<LandingPage
allData={homePage}
socials={globalData?.header?.socialMedia}
/>
</WebsiteUserLayout>
)
}