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

HTTP fetch even when project is generated #22948

Closed
Barbapapazes opened this issue Sep 1, 2023 · 5 comments · Fixed by nuxt/content#2280
Closed

HTTP fetch even when project is generated #22948

Barbapapazes opened this issue Sep 1, 2023 · 5 comments · Fixed by nuxt/content#2280

Comments

@Barbapapazes
Copy link
Contributor

Barbapapazes commented Sep 1, 2023

Environment


  • Operating System: Linux
  • Node Version: v20.5.1
  • Nuxt Version: 3.6.5
  • Nitro Version: 2.6.2
  • Package Manager: pnpm@8.7.1
  • Builder: vite
  • User Config: modules, content
  • Runtime Modules: @nuxt/content@2.8.1
  • Build Modules: -

Reproduction

https://github.com/Barbapapazes/fetch-made-even-with-generated

  1. Clone the project
  2. Install deps
  3. Generate project using npm run generate
  4. Go to localhost:3000
  5. Navigate to /about and take a look at the network tab in the inspector. You will see that a request is made to ungh.cc despite that the project is generated and the content inside the payload.

Describe the bug

useFetch query data despite that the project is generated and content inside the payload.

When we navigate from / to /about, an http call is made but when going directly to /about payload is load so no nitro call is made. Will try without nuxt/content.

Without the content module, https://github.com/barbapapazes/fetch-made-even-with-generated-without-content, the payload is fetched when navigating between home and about.

Additional context

No response

Logs

No response

@Barbapapazes
Copy link
Contributor Author

related to #22841 and could be related to @nuxt/content module.

@Barbapapazes
Copy link
Contributor Author

when payload is not fetched, https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/plugins/payload.client.ts#L6, return before calling link:prefetch.

@Barbapapazes
Copy link
Contributor Author

export function isPrerendered() {
  const nuxtApp = useNuxtApp();
  return !!nuxtApp.payload.prerenderedAt;
}

And here the payload

[{"state":1,"_errors":128,"serverRendered":130,"path":7,"prerenderedAt":-1}]

Do you have it? Yes, prerender is set to -1 so payload is never fetched.

@Barbapapazes
Copy link
Contributor Author

Barbapapazes commented Sep 1, 2023

Here the issue 🤨 https://github.com/nuxt/content/blob/main/src/runtime/legacy/plugins/documentDriven.ts#L298#22947

But why? (for studio?)

Using document-driven mode, payload is never fetched. And this could explained why there is http call (fetch parsed md files).

@Barbapapazes
Copy link
Contributor Author

related to nuxt/content#1526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant