Skip to content

404 Error for Translated Versioned Index Document #11112

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

Open
5 of 7 tasks
LuggaLugga opened this issue Apr 17, 2025 · 1 comment
Open
5 of 7 tasks

404 Error for Translated Versioned Index Document #11112

LuggaLugga opened this issue Apr 17, 2025 · 1 comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus.

Comments

@LuggaLugga
Copy link

LuggaLugga commented Apr 17, 2025

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

For the explanation, it's sufficient to assume that there's only one document, index.mdx, located under /docs. I have versioned this document for versions 1.0.0 and 2.0.0. Version 2.0.0 represents the current version. Additionally, /docs also represents the next version. My documentation is also internationalized into de, alongside the default en.

With this setup, the document should be accessible in English at /1.0.0, /, and /next, and in German at /de/1.0.0, /de, and /de/next. All these paths correctly serve the corresponding document after running npm run build and npm run serve, except for /de/1.0.0, which returns a 404 error.

While searching for the cause of this issue, I noticed the following:

  • If I add another versioned and internationalized document intro.mdx to /docs, it is correctly served under /de/1.0.0/intro after running npm run build and npm run serve.

  • When I run npm run start -- --locale de, the document is correctly served on every path.

  • If I rename the version 1.0.0 to abc, the document is correctly served on all paths after npm run build and npm run serve.

  • If I add another versioned and internationalized document index.mdx in /docs/tutorial, this one is also not accessible under /de/1.0.0/tutorial after npm run build and npm run serve.

Reproducible demo

https://github.com/LuggaLugga/docusaurus-bug-demo

Steps to reproduce

  1. Build the demo with npm run build
  2. Run the demo with npm run serve
  3. Navigate to http://localhost:3000/de/1.0.0

Expected behavior

I expect the document from i18n/de/docusaurus-plugin-content-docs/version-1.0.0/index.mdx to be rendered.

Actual behavior

The document from i18n/de/docusaurus-plugin-content-docs/version-1.0.0/index.mdx is not accessible according to the 404 error code.

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@LuggaLugga LuggaLugga added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 17, 2025
@slorber
Copy link
Collaborator

slorber commented Apr 18, 2025

This is not a docusaurus build bug: the expected static file is here: build/de/1.0.0/index.html

This looks like a bug in docusaurus serve, probably coming from our dependency https://github.com/vercel/serve-handler: the /de/1.0.0/ and /de/1.0.0/index.html pathnames always redirect to /de/1.0.0 for some reason.

I can also reproduce by running npx serve build, so it's likely not a Docusaurus bug and should probably be reported to the underlying package that has the bug with a minimal repro.

Using an alternate server works: npx http-server build will serve your page

If you deploy your site on a CDN, it should work fine.

@slorber slorber added external This issue is caused by an external dependency and not Docusaurus. and removed status: needs triage This issue has not been triaged by maintainers labels Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus.
Projects
None yet
Development

No branches or pull requests

2 participants