Replies: 1 comment
-
See #9524 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
In my front page, I have made query data from CMS and passed to the front page:
Below is the piece of code in my exportPathMap function:
And in my Index.getInitialProps() function, I did the same API call and return it as the initial props:
Coz I have followed the tutorial from here: Fetching Data for Pages
https://nextjs.org/learn/basics/fetching-data-for-pages
I've checked the server request logs and found that during the page is rendered in server side, the API will be requested. It's fine. When jumping to other page and going back to the front page (using <Link> not <a>), the Index.getInitialProps() gets called again and so does the API endpoint call.
Is this the normal usage? I think it's not 100% static. Suppose the API end point cannot be accessed for the public. It must be used during the build and export phase.
The index.html must be generated in early time and content should be generated to meet the SEO purpose. So what is the recommended and correct usage in my case?
Thanks!!!!!
Beta Was this translation helpful? Give feedback.
All reactions