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

fix(prerender): avoid detecting .json routes as implicit html #1962

Closed
wants to merge 1 commit into from

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Nov 28, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

On investigation, there are cases where a framework renderer, returns text/html responses for routes ending with .json extension. Content is most likely also wrong (it does not fix nuxt/nuxt#24487 only generates manifest.json with HTML in it!) but at least avoids making wrong structure.

(root cause is that Nuxt ordering is different and first prerenders and then copies public assets)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -220,7 +220,9 @@ export async function prerender(nitro: Nitro) {
// Guess route type and populate fileName
const contentType = res.headers.get("content-type") || "";
const isImplicitHTML =
!route.endsWith(".html") && contentType.includes("html");
!route.endsWith(".html") &&
!route.endsWith(".json") &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add .xml perhaps...

Copy link
Member Author

@pi0 pi0 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we could make a list also (for like . webmanifest ) but consider this is mainly a hotfix for when content-type is also wrongly text/html...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A safelist is probably not a bad idea given this is only for implicit content type...

@pi0
Copy link
Member Author

pi0 commented Nov 28, 2023

#1963

@pi0 pi0 closed this Nov 28, 2023
@pi0 pi0 deleted the fix/prerender-json branch November 28, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manifest.json becomes a folder with index.html instead of a JSON file
2 participants