diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a96eaab5f..10e30a4a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,24 @@ Our versioning strategy is as follows: ## Unreleased +## 21.1.6 + +### 🐛 Bug Fixes + +`[templates/nextjs-sxa]` Add condition DISABLE_SSG_FETCH for 404/500 pages to enable full ISR (Incremental Static Regeneration) flow ([#1496](https://github.com/Sitecore/jss/pull/1496)) + +## 21.1.5 + +### 🐛 Bug Fixes + +* `[create-sitecore-jss]` Change ^ to ~ for versioning in templates and use exact versions for sitecore-jss monorepo dependencies. + +## 21.1.4 + +### 🐛 Bug Fixes + +* `[create-sitecore-jss]` Change ^ to ~ for versioning in templates. + ## 21.1.3 ### 🐛 Bug Fixes diff --git a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/404.tsx b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/404.tsx index e8749fe25d..d291476e0b 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/404.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/404.tsx @@ -1,5 +1,9 @@ import config from 'temp/config'; -import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs'; +import { + GraphQLErrorPagesService, + SitecoreContext, + ErrorPages, +} from '@sitecore-jss/sitecore-jss-nextjs'; import { SitecorePageProps } from 'lib/page-props'; import NotFound from 'src/NotFound'; import { componentFactory } from 'temp/componentFactory'; @@ -27,8 +31,16 @@ export const getStaticProps: GetStaticProps = async (context) => { siteName: site.name, language: context.locale || config.defaultLanguage, }); + let resultErrorPages: ErrorPages | null = null; - const resultErrorPages = await errorPagesService.fetchErrorPages(); + if (!process.env.DISABLE_SSG_FETCH) { + try { + resultErrorPages = await errorPagesService.fetchErrorPages(); + } catch (error) { + console.log('Error occurred while fetching error pages'); + console.log(error); + } + } return { props: { diff --git a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/500.tsx b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/500.tsx index 21776ed951..df99435f02 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/500.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/500.tsx @@ -1,5 +1,9 @@ import Head from 'next/head'; -import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs'; +import { + GraphQLErrorPagesService, + SitecoreContext, + ErrorPages, +} from '@sitecore-jss/sitecore-jss-nextjs'; import { SitecorePageProps } from 'lib/page-props'; import Layout from 'src/Layout'; import { componentFactory } from 'temp/componentFactory'; @@ -43,8 +47,16 @@ export const getStaticProps: GetStaticProps = async (context) => { siteName: site.name, language: context.locale || context.defaultLocale || config.defaultLanguage, }); + let resultErrorPages: ErrorPages | null = null; - const resultErrorPages = await errorPagesService.fetchErrorPages(); + if (!process.env.DISABLE_SSG_FETCH) { + try { + resultErrorPages = await errorPagesService.fetchErrorPages(); + } catch (error) { + console.log('Error occurred while fetching error pages'); + console.log(error); + } + } return { props: {