nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
54.66k stars 5k forks source link

Nuxt generate no longer generating dynamic Nuxt/Content pages when deploying #23356

Closed StefanVDWeide closed 1 year ago

StefanVDWeide commented 1 year ago

Environment

Reproduction

N/A

Describe the bug

When running npm run generate locally all the pages in my /content folder are being generated. However, when deploying to render.com and having it run the same command to generate the static content, all the dynamic pages are skipped over. This results in 404 errors when trying to navigate to those pages.

The dynamic pages are all being linked to from a blog page overview /blog where each entry has a specific link e.g. /blog/example. The blog overview page is rendered correctly since this is not based on a markdown file but rather a .vue file.

My content folder looks fairly standard:

This setup has always worked, only after upgrading to Nuxt/Content 2.8.2 from 2.6.0 and Nuxt itself from 3.4.3 to 3.7.3 it started failing on render.com. Reverting back does solve this issue but isn't ideal ofcourse.

I've attached the build logs from a local sucessful build and an incomplete build on render.com

Locally: https://pastebin.com/fs6kXcV2 render.com: https://pastebin.com/g5yvS0PS

Thanks!

Additional context

No response

Logs

No response

danielroe commented 1 year ago

This sounds like a likely issue with nuxt/content. Can you try confirming which upgrade caused it? If it was nuxt/content, would you raise an issue there instead?

github-actions[bot] commented 1 year ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz 👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
StefanVDWeide commented 1 year ago

@danielroe when trying to downgrade Nuxt/Content back to 2.6.0 and leaving Nuxt at 3.7.3 I'm having the same issue where locally everything is generated, but on my prod environment the dynamic pages are skipped.

Some more context, these are the errors I'm seeing in the console. It seems the JSON payloads are missing and causing issues down the line.

GET https://studioterabyte.nl/blog/serverless-stack/_payload.json 404
entry.4513e066.js:1 [nuxt] Cannot load payload  /blog/serverless-stack/_payload.json SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Interestingly, when downgrading Nuxt to 3.4.3 and leaving Nuxt/Content at 2.8.2 the pages are generated again as expected. So it seems an issue on the Nuxt side of things.

Looks like I'm not the only one with this issue too: https://stackoverflow.com/questions/77077036/nuxt-3-static-site-payload-json-not-found-404-due-to-wrong-route-on-request#comment136014809_77077036

danielroe commented 1 year ago

A reproduction would be very helpful then.

StefanVDWeide commented 1 year ago

Alright, while setting up the reproduction everything of course worked perfectly.

Looking at the differences between the reproduction and what I have installed for my website, I noticed a difference in Nuxt/i18n versions. The repoduction used the latest RC version and my own site the Edge version. After upgrading my own version to the latest RC one, and turning off the experimental payload extraction, everything seems to be working again.

For some reason the incorrect locale paths were generated and skipped over during the generate phase. Turning off the payload extraction ensured that when I switch locale when on a dynamic page, the page itself also changes.

Not sure what is going wrong between Nuxt and the i18n edge version but I'm glad this is resolved.

Thanks for the quick response!