nuxt: Nuxt Generate - Page not showing any content client side, works fine server side.
Versions
- nuxt: 2.14.3
- node: 10.13.0
Reproduction
This repo: https://github.com/funkhaus/fuxt
Demo is here: https://fuxt-funkhaus.netlify.app
Steps to reproduce
- Rename
.example.envto.env - Use
nuxt generateon above repo and deploy to Netlify (ornuxt startlocally) - Load any page on the site (https://fuxt-funkhaus.netlify.app), content loads off server fine.
- Browse to any other page via
nuxt-linkand page new will be empty of any dynamic content.
What is Expected?
Client side browsing should load content from payload onto the page.
What is actually happening?
So it seems server side is working fine. But client side is not. If you look at the network inspector in your browser as you move around the site, you’ll see that payload.js is loading and looks to contain the correct code, but it never makes it onto the page for some reason.
The site only contains a few fetch() methods here:
https://github.com/funkhaus/fuxt/blob/master/pages/_page.vue
https://github.com/funkhaus/fuxt/blob/master/components/WpMenu.vue
https://github.com/funkhaus/fuxt/blob/master/components/WpSeo.vue
And a request in nuxtServerInit here:
https://github.com/funkhaus/fuxt/blob/master/store/index.js#L60
It all seems to be inline with the way you recommend the use of fetch(), so I’m not sure what is not working? Perhaps it doesn’t like GQL? Or the use of lodash _get in the fetch()?
I wish there was more explanation of what nuxt generate and payload is doing behind the scenes so I could troubleshoot this myself.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 33 (14 by maintainers)
I ran into this with using
asyncDataandtarget: 'static'– you can see this e.g. here:https://www.virtualsupporttalks.de/impressum/
If you open that page directly, you can see the content is there because it’s correctly rendered server side. But it’s gone after a moment and the page is blank.
Also, I get this warning:
What I found strange when looking into the
payload.jsfile: It starts with__NUXT_JSONP__("/impressum", (function(a, b…I’ve set the
trailingSlashrouter property in mynuxt.config.jsin order to make everything work with Netlify. Which in my wild guesses should result in thepayload.jshaving this output:__NUXT_JSONP__("/impressum/", (function(a, b…. Or whatever handles the payload should be able to handle the trailing slash?So I tried removing this and… everything works 😅 Could this be the problem? I have to add the
trailingSlashoption again, of course, because Netlify needs this. Unfortunately, this makes it impossible to link to these pages directly for now 😑EDIT: Nevermind, this problem is already mentioned here https://github.com/nuxt/nuxt.js/issues/8476 and should be solved here: https://github.com/nuxt/nuxt.js/pull/8489 – how satisfying that I was on the right track, though 😄
@adamdehaven @drewbaker Really appreciate your checking on this - you definitely caught a significant regression before release ❤️ - see #8802
We are a bit late on schedule since 2.15 includes a bigger change regarding PostCSS 8 so we need more internal testing before 😄
@drewbaker It should land in 2.15…
So I’m bumping this again to ask if this can be rolled out soon as part of a
2.14.xrelease, asnuxtis not usable with thegeneratecommand without this fix in place and it appears that2.15is not being rolled out yet. Possible?I can confirm this resolves the issue for me as well (tested in
nuxt-edge 2.15.0-26830131.c15078fa) – much appreciated. Ship it 🚢 👍🏼Thanks @danielroe this is so massive for us. Love this. Thank you for fixing!
Ran into some unrelated build errors over here https://github.com/nuxt/nuxt.js/issues/8508
Can confirm this works in
nuxt-edge, so happy!When do you think this will land in a core 2.x release?
Closed in https://github.com/nuxt/nuxt.js/pull/8466. Would appreciate testing via
nuxt-edgeto confirm fix.