getInitialProps makes 404 and search render as SSR
See original GitHub issueIssue Description
We’re using getInitialProps in _app.js to allow us to have a “global” data layer
Beyond the general recommendation to steer away from it to use newer methods, turns out if you use it and your page doesn’t use any other data fetching method, it assumes SSR
We need to add simple stubs of static props on any pages not using any data fetching simply to turn on static generation for those pages
export async function getStaticProps() {
return {
props: {},
};
}
Pages that need this added:
- /search
- /404
Please confirm by running build that all pages are statically generated
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Next.js return the 404 error page in getInitialProps
Next v10 allows to return 404 page (not with props, ... In order to do that, you'll have to render the Error page...
Read more >Way to return 404 http error code in render() #4452 - GitHub
Right now you can return 404 http error code only in getInitialProps, which is not nice, since you have to fetch the data...
Read more >How to return a 404 error in getServerSideProps with Next.js
To search engines, this essentially translates to: "Everything went fine and we found the page". Rather than actually responding with a 404 , ......
Read more >What is Next.js getInitialProps and getServerSideProps? | refine
getInitialProps is an asynchronous function used for fetching data on the server and pre-rendering the resulting data (aka server-side rendering) ...
Read more >getServerSideProps vs getInitialProps getStaticProps in Next.js
getInitialProps is used to enable Server-Side Rendering, or SSR for a page. With SSR, the HTML is generated on the server when it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Go for it! All yours
On Sun, Oct 3, 2021 at 10:58 AM Peter Cruckshank @.***> wrote:
– colbyfayock.com
Fixed via https://github.com/colbyfayock/next-wordpress-starter/pull/252