Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#585891: fixed 404/500 added DISABLE_SSG_FETCH params #1496

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Our versioning strategy is as follows:
* `[angular]` Avoid sending two dictionary service calls when switching language and refreshing the page ([#1473](https://github.com/Sitecore/jss/pull/1473))
* Fix installed sitecore-jss-* dependency version ([#1478](https://github.com/Sitecore/jss/pull/1478))
* [node-headless-ssr-experience-edge] Add helper comment for rootItemId ([#1491](https://github.com/Sitecore/jss/pull/1491))
* `[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

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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: {
Expand Down