Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
263 stars 275 forks source link

DISABLE_SSG_FETCH is broken #1808

Open GAAOPS opened 5 months ago

GAAOPS commented 5 months ago

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:

To Reproduce

Run: npx create-sitecore-jss@^22.0.0 nextjs with the following options:

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

GAAOPS commented 5 months ago

I found a workaround for the issue, to prevent the build issue when you want to disable the SSG, in your .env file: DISABLE_SSG_FETCH=true GRAPH_QL_ENDPOINT=http://nonexisting/ Just filling out GRAPH_QL_ENDPOINT with something will solve the issue.

Nevertheless, it is a bug.

yavorsk commented 5 months ago

Thanks @GAAOPS for submitting this! We created an item in our backlog to look into it.