Ignore GSSP on next export
See original GitHub issueFeature request
I expected next export
to exclude any pages featuring GSSP. The desire is to use next’s built-in method to hoist all static content to a particular folder.
Is your feature request related to a problem? Please describe.
I am re-working the Firebase examples and want to leverage the Firebase CDN in a better way. Firebase Hosting priority order can be used to have all static resources on Firebase Hosting served first by the CDN and any request misses be fulfilled by the Cloud Functions hosted Next.js app. This requires me to run next export
(I want to avoid duplicating this functionality myself) to produce the static resources to push to the CDN.
However, with SSG, the page is computed by the backend a single time if missing. I desire some pages to be SSR with GSSP.
Describe the solution you’d like
I would like a flag for next export
to override the existing behavior which errors with:
Error occurred prerendering page "/index". Read more: https://err.sh/next.js/prerender-error:
Error: Error for page /index: pages with `getServerSideProps` can not be exported. See more info here: https://err.sh/next.js/gssp-export
For example: next export --ignore-gssp
which performs as it does today, but skips pages with GSSP.
Describe alternatives you’ve considered
Using SSG mode with an empty paths paths:[], fallback:true
works with next export
and forces all content to be computed on request (doesn’t generate any build time .html
or .json
), but only once. This method also only works for dynamic routes /posts/[id].js
. Not quite the behavior I want.
Using SSG mode with a per-page CDN cache flush is also a possibility, though highly dependent on the Hosting service. Firebase for instance, does not have any CDN cache flush or cache control outside of s-maxage
. CDN cache flushing would also require tracking of BUILD_ID as it is used in the path for the .json
data.
Using SSR mode with a large s-maxage
& CDN cache flush is also possible, again, dependent on Hosting service and it’s availability of cache flushing.
I have considered:
-
creating my own copy command to perform the hoist of static resources. From the source I can see:
1. (copy static folder) .next/static -> out/_next/static 2. (copy SSG .html files (without route regex in name)) .next/server/static/{build_id}/pages -> out/ 3. (copy SSG .json data files) .next/server/static/{build_id}/pages -> out/_next/data/{build_id} 4. (copy public folder) public -> out/
This way I wouldn’t need to use
next export
, dynamic-route SSG pages would be computed on first request and SSR pages on each request 🤔
Additional context
next 9.3.5
For those finding this, I have created an example script: https://gist.github.com/jthegedus/8e820d37e1f3768f991886fb65de154f
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:5 (3 by maintainers)
Top GitHub Comments
A flag for this command like
next export --ignore-gssp
wouldn’t change this for existing users.Other Hosting platforms would be able to utilise this for Next.js support without having to worry about any internal changes to the build output.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.