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

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

Closed
5 tasks done
tkow opened this issue Oct 1, 2021 · 6 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)

Comments

@tkow
Copy link

tkow commented Oct 1, 2021

🐛 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

@tkow tkow 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 Oct 1, 2021
@slorber
Copy link
Collaborator

slorber commented Oct 1, 2021

This issue is very hard to understand for me, can you explain it more simply?

Instead of written text, just give me an example: which request is routed to which static file with start/prod mode. A matrix with factual data would be way easier to understand for me.

Is this issue a duplicate of #4971?

Dev is using webpack-dev-server package
Prod is using serve package

The way those servers behave may be slightly different and we may not have options to make them behave 100% in the same way, even if it would be ideal.

@tkow
Copy link
Author

tkow commented Oct 1, 2021

I took a movies.

These demo structure is located here.

Dev mode

dev-demo-min.mov

Prod mode

build-serve-demo-min.mov

Especially we have trouble by disallowing directory name have "." string in production because we want to host our static html integrated by auto-generated by sphinx has including "." directory. Is the way to avoid this misrouting with directory "." included?

@tkow
Copy link
Author

tkow commented Oct 1, 2021

In addition, when we use

python -m http.server 8000 --directory ./static 

we get different result from above because it doesn't rewrite url and we usually prefer this behavior as default hosting static site. It is convenient if we switch the static directory configuration that disable rewriting for example.

Is this issue a duplicate of #4971?

As I see it, It is not because base directory may not be related to html file links relative path routing above shows.

@tkow
Copy link
Author

tkow commented Oct 2, 2021

@slorber

I read serve command's implements and I got that serve command is not necessary when we use build artifact as simple static site without backend router. So I found this issue is trivial when use alternative web server or hosting static site storage service instead of using docusaurus serve command. We simply run python -m http.server --directory build and it works well. It hosts theme. So I write adhoc http server script in node.js for my project. Thank you for your opinions.

In Addition

We use http-server package for web server which run server from cli without configuration.

@slorber
Copy link
Collaborator

slorber commented 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

@Josh-Cena Josh-Cena added status: needs triage This issue has not been triaged by maintainers and removed status: needs triage This issue has not been triaged by maintainers labels Oct 30, 2021
@Josh-Cena Josh-Cena added closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed status: needs triage This issue has not been triaged by maintainers labels Jan 29, 2022
@Josh-Cena
Copy link
Collaborator

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

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 closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)
Projects
None yet
Development

No branches or pull requests

3 participants