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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...

contentType.includes("html");
const routeWithIndex = route.endsWith("/") ? route + "index" : route;
const htmlPath =
route.endsWith("/") || nitro.options.prerender.autoSubfolderIndex
Expand Down