facebook / facebook/docusaurus

404 page in dev server returns 200 status code instead of 404

オープン
#11,095 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る
bug status: needs triage
主要言語
TypeScript
スター
66.2k
フォーク
10k
平均マージ
1日 3時間
マージ済み PR(30日)
52

説明

### Have you read the Contributing Guidelines on issues?

- [x] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

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

### Description

If you try to access to assets that don't exist, they must be 404, but 200 are returned. It makes harder to debug because it is confusing with existing assets.
If you try to load static CSS files in your site, the content of 404 page will be tried to be interpreted as CSS.

### Reproducible demo

_No response_

### Steps to reproduce

1. Create a Docusaurus site
2. `node --run start` (Node 22)
3. Launch your browser
4. Press F12 to open the Dev tab, then switch to "Network" tab
5. Open http://localhost:3000/foo/bar/baz/qux/quux or a URL in localhost:3000 where no page exists
6. Check its status code

Instead of 3–6, you can run `curl -I http://localhost:3000/foo/bar/baz/qux/quux`.

### Expected behavior

Status code is 404

### Actual behavior

Status code is 200

![Image](https://github.com/user-attachments/assets/27a2f2f5-ccf0-4d2a-a61e-412ba1d13193)

```
$ curl -I http://localhost:3000/foo/bar/baz/qux/quux
HTTP/1.1 200 OK
X-Powered-By: Express
access-control-allow-origin: *
Content-Type: text/html; charset=utf-8
Accept-Ranges: bytes
Content-Length: 2106
ETag: W/"83a-NUMvx01I1roo/HRoilxs0XiYpLg"
Vary: Accept-Encoding
Date: Sun, 20 Apr 2025 14:47:05 GMT
Connection: keep-alive
Keep-Alive: timeout=5
```

### Your environment

- Public source code:
- Public site URL:
- Docusaurus version used: 3.7.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node 22.13.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 11

### Self-service

- [ ] I'd be willing to fix this bug myself.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。