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

DISABLE_SSG_FETCH is broken #1808

Open
GAAOPS opened this issue Jun 4, 2024 · 2 comments
Open

DISABLE_SSG_FETCH is broken #1808

GAAOPS opened this issue Jun 4, 2024 · 2 comments
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug

Comments

@GAAOPS
Copy link

GAAOPS commented Jun 4, 2024

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 from getStaticPaths it still does not work. i need to remove import { 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): -
@GAAOPS GAAOPS added the 🐞 bug label Jun 4, 2024
@GAAOPS
Copy link
Author

GAAOPS commented Jun 5, 2024

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
Copy link
Contributor

yavorsk commented Jun 5, 2024

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

@yavorsk yavorsk added the backlog Issue/PR/discussion is reviewed and added to backlog for the further work label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug
Projects
None yet
Development

No branches or pull requests

2 participants