Skip to content

"You are trying to create client-side redirections to paths that do not exist" to folders without trailing slash #8016

@SheetJSDev

Description

@SheetJSDev

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 paths to folders without a trailing slash, hosts will typically 302 redirect to the path with the slash

e.g. https://docs.sheetjs.com/docs/getting-started redirects to https://docs.sheetjs.com/docs/getting-started/

@docusaurus/plugin-client-redirects does not seem to be aware of this behavior for folders that have subfolders.

This redirect works

        { from: '/docs/installation', to: '/docs/getting-started/' }, // works

This redirect elicits the error mentioned in the title:

        { from: '/docs/installation', to: '/docs/getting-started' }, // elicits error

The fact that it works for leaf folders that only have index.html suggests this is a bug in the redirect scanner:

        { from: '/docs/example', to: '/docs/getting-started/example' }, // this works, even though `example` is a folder

Reproducible demo

https://github.com/SheetJS/docs.sheetjs.com

Steps to reproduce

git clone --depth=1 https://github.com/SheetJS/docs.sheetjs.com
cd docs.sheetjs.com/docz
npm i
npm run build ## note: this should work
sed -I '' "s#started/'#started'#g" docusaurus.config.js
npm run build ## this will fail with the aforementioned error

If the sed command fails, the edit is in docusaurus.config.js:

       redirects: [
         { from: '/docs/example', to: '/docs/getting-started/example' },
-        { from: '/docs/installation', to: '/docs/getting-started/' },
+        { from: '/docs/installation', to: '/docs/getting-started' },
       ]
     }]

Expected behavior

It should create the redirect

Actual behavior

[ERROR] Error: You are trying to create client-side redirections to paths that do not exist:

The path in question is not listed in the valid paths

Your environment

No response

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiondomain: trailing slashRelated to trailing slash config

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions