jss
jss copied to clipboard
DISABLE_SSG_FETCH is broken
Describe the Bug
I have started a new project with Sitecore XM1, SXA and nextjs@22. Because of the network restriction I need to turn off the SSG during build process. After Setting DISABLE_SSG_FETCH=true
the build is failing in three places:
- in 'src\pages[[...path]].tsx': the issue is with
sitemapFetcher
, even if I remove the whole code fromgetStaticPaths
it still does not work. i need to removeimport { sitemapFetcher } from 'lib/sitemap-fetcher';
- Second and third issues are in error pages 404 and 500.
To Reproduce
Run: npx create-sitecore-jss@^22.0.0 nextjs
with the following options:
- How would you like to fetch Layout and Dictionary data: GraphQL
- How would you like to prerender your application: SSG
- Are you building for Sitecore XM Cloud: No
- Would you like to include any add-on initializers: nextjs-sxa , nextjs-multisite
After it is finished, set the DISABLE_SSG_FETCH=true
in the .env
file and run npm run build
Expected Behavior
Setting the DISABLE_SSG_FETCH=true
should prevent requests to the edge endpoint and the build should not fail.
Possible Fix
I dont know how the first issue with sitemapFetcher can be fixed but for 404,500 pages there is an easy fix: the whole code inside the getStaticProps should be inside if (!process.env.DISABLE_SSG_FETCH)
.
Provide environment information
- Sitecore Version:10.4
- JSS Version:22.0
- Browser Name and version: -
- Operating System and version (desktop or mobile): Windows 11
- Link to your project (if available): -