#[nuxt] Cannot load payload /_payload.json

17 messages · Page 1 of 1 (latest)

fathom garden
#

I just created a brand new Nuxt project using npx nuxi@latest init. I set up routing by adding <NuxtPage /> to app.vue and creating pages/index.vue. Then I made a static export using npm run generate and finally I serve it using npx serve .output/public.

I am getting the following error in my browser's console:

[nuxt] Cannot load payload  /hello/_payload.json SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Why is Nuxt is trying to load a non-existent JSON file? Did I find a bug already? 😬

fathom garden
#

@orchid roost ^ I am going to bed now so hopefully you don't mind me just tagging you instead of replying to the PR or making an issue 😅

fathom garden
fathom garden
#

@orchid roost where does the payload come from if I set payloadExtraction to false? I noticed that no request is being made now if I browse to another page

#

I am not using useFetch or anything like that so I suppose there shouldn't be a payload anyway but with payloadExtraction set to true it does generate one for every page

#

I am not too familiar with Nuxt so if this makes no sense please let me know 😅

orchid roost
#

Nuxt saves the content of every useasyncdata/usefetch call in a payload when doing this, so they won't be refetched when client-side navigation. otherwise they will be refetched on client side navigation even though they won't on hard reloads

fathom garden
#

And is it really necessary to generate a payload for pages that do not use useFetch or related?

#

SvelteKit for example creates a __data.json (equivalent to Nuxt's _payload.json) only if you have a server-side load

#

I also noticed that Nuxt does not prefetch the payload (like when you hover over a link for example), this would be a nice feature too

orchid roost
fathom garden
bold pelican