Skip to content

Commit ec1a12d

Browse files
author
Teo
authored
Issue # 23 remove isr on homepage to fix 500 error (#763)
* fix: replace ISR with SSR on homepage to prevent 500 error
1 parent 8d663f2 commit ec1a12d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ cypress/screenshots
6363
public/sitemap.xml
6464
public/robots.txt
6565
/instrumented/
66+
67+
# Netlify CLI
68+
.netlify

src/pages/index.page.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ export default function HomePage({
3434
</>
3535
);
3636
}
37-
3837
export async function getStaticProps() {
39-
const posts = await getBlogspotPosts().catch(() => []);
40-
const props = { blogPosts: posts.slice(0, 8) };
41-
42-
const isDeployPreview = process.env.CONTEXT === "deploy-preview";
43-
if (isDeployPreview) {
44-
return { props };
45-
} // fully static for previews
46-
return { props, revalidate: 3600 }; // ISR for prod
38+
try {
39+
const posts = await getBlogspotPosts();
40+
return { props: { blogPosts: posts.slice(0, 8) } };
41+
} catch {
42+
return { props: { blogPosts: [] } };
43+
}
4744
}

0 commit comments

Comments
 (0)