question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docusaurus start and docusaurus build && docusaurus serve have different routing rule about static folder

See original GitHub issue

🐛 Bug Report

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

If you use docusaurus start static folder routings are

  • no accessable if file dir has “.” string and file destination url can omit /index path
  • accessable even if dir name has “.” string and the filename is not index.html (can’t omit part of url derive from filename)

If you use docusaurus build and serve static folder routings are

  • no accessable if file name has “.” string
  • accessable even if dir name has “.” string

As I thought it, Docusaurus shouldn’t rewrite url about static folder resources because its files are tended to be linked by idempotent routing rule and may not depend on hosting server rewriting rule as default.

Have you read the [Contributing Guidelines on issues]

yes

Steps to reproduce

To reproduce, we need build step so I made repository for this because I can’t find the way to do using sanbox.

Demo: https://github.com/tkow/docusaurus-url-denied-demo

  1. Pull code from master branch and setup project: npm install
  2. Run npm run start and access localhost:3000/html in browser
  3. List of links appears having message of whether or not be accessible when using docusaurus build and docusaurus serve and check mismatching between the results of navigating and showing messages by clicking links.
  4. Run npm run build && npm run serve and access localhost:3000/html in browser
  5. List of links appears having message of whether or not be accessible when using docusaurus build and docusaurus serve and check matching between the results of navigating and showing messages by clicking links.

Expected behavior

We have same routings between docsaurus start and docsaurus build and docsaurus serve. And static route should not be applied rewrite rules as default.

Actual behavior

We have different routings result between docsaurus start and docsaurus build and docsaurus serve.

Your environment

    "@docusaurus/core": "2.0.0-beta.6"
    "@docusaurus/preset-classic": "2.0.0-beta.6"
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Chrome version: 94.0.4606.61(Official Build) (x86_64, Node.js v12.22.1
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS Big Sur version 11.5.2(20G95)

Reproducible demo

https://github.com/tkow/docusaurus-url-denied-demo

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
slorbercommented, Oct 5, 2021

Hi @tkow

docusaurus serve is mostly a tool we provide for convenient local testing. In production you’d rather use a more advanced HTTP server for static files that you can configure according to your own needs, preferably a CDN for performance reasons.

I still think that we can keep this issue open because we should try to make the dev & build/serve similar if possible, but we may close later this issue as wontfix if it’s not possible to do so

0reactions
Josh-Cenacommented, Jan 29, 2022

Closing as wontfix, because we neither control the routing of start nor serve. I also believe #5420 would have fixed it already.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing - Docusaurus
Pages routing are straightforward: the file paths directly map to URLs, without any other way to customize. See the pages docs for more ......
Read more >
Deployment - Docusaurus
Deploy your Docusaurus app for production on a range of static site hosting services.
Read more >
Static Assets - Docusaurus
Static assets are the non-code files that are directly copied to the build output. They include images, stylesheets, favicons, fonts, etc.
Read more >
Static site generation (SSG) - Docusaurus
Strictly speaking, Docusaurus is a static site generator, because there's no server-side runtime—we statically render to HTML files that are ...
Read more >
CLI - Docusaurus
Docusaurus provides a set of scripts to help you generate, serve, and deploy your website.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found