You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Express 5, the `express.static` middleware's `dotfiles` option now defaults to `"ignore"`. This is a change from Express 4, where dotfiles were served by default. As a result, files inside a directory that starts with a dot (`.`), such as `.well-known`, will no longer be accessible and will return a **404 Not Found** error. This can break functionality that depends on serving dot-directories, such as Android App Links, and Apple Universal Links.
476
+
477
+
Example of breaking code:
478
+
479
+
```js
480
+
// v4
481
+
app.use(express.static('public'))
482
+
```
483
+
484
+
After migrating to Express 5, a request to `/.well-known/assetlinks.json` will result in a **404 Not Found**.
485
+
486
+
To fix this, serve specific dot-directories explicitly using the `dotfiles: "allow"` option:
This approach allows you to safely serve only the intended dot-directories while keeping the default secure behavior for other dotfiles, which remain inaccessible.
495
+
472
496
<h3id="app.listen">app.listen</h3>
473
497
474
498
In Express 5, the `app.listen` method will invoke the user-provided callback function (if provided) when the server receives an error event. In Express 4, such errors would be thrown. This change shifts error-handling responsibility to the callback function in Express 5. If there is an error, it will be passed to the callback as an argument.
Copy file name to clipboardExpand all lines: de/guide/using-middleware.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ redirect_from: " "
10
10
11
11
Express ist ein Weiterleitungs- und Middleware-Web-Framework, das selbst nur minimale Funktionalität aufweist: Eine Express-Anwendung besteht im Wesentlichen aus einer Reihe von Middlewarefunktionsaufrufen.
12
12
13
-
_Middlewarefunktionen_ sind Funktionen, die Zugriff auf das [Anforderungsobjekt](/{{ page.lang }}/4x/api.html#req) (`req`), das [Antwortobjekt](/{{ page.lang }}/4x/api.html#res) (`res`) und die nächste Middlewarefunktion im Anforderung/Antwort-Zyklus der Anwendung haben. Die nächste Middlewarefunktion wird im Allgemeinen durch die Variable `next` bezeichnet.
13
+
_Middleware_ functions are functions that have access to the [request object](/{{ page.lang }}/5x/api.html#req) (`req`), the [response object](/{{ page.lang }}/5x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. Die nächste Middlewarefunktion wird im Allgemeinen durch die Variable `next` bezeichnet.
14
14
15
15
Über Middlewarefunktionen lassen sich die folgenden Tasks ausführen:
16
16
@@ -34,7 +34,7 @@ Sie können auch eine Reihe von Middlewarefunktionen zusammen laden. Dadurch wir
34
34
35
35
<h2id='middleware.application'>Middleware auf Anwendungsebene</h2>
36
36
37
-
Binden Sie Middleware auf Anwendungsebene zu einer Instanz des [Anwendungsobjekts](/{{ page.lang }}/4x/api.html#app), indem Sie die Funktionen `app.use()`und`app.METHOD()`verwenden. `METHOD`ist dabei die HTTP-Methode der Anforderung, die die Middlewarefunktion in Kleinschreibung verarbeitet (wie GET, PUT oder POST).
37
+
Bind application-level middleware to an instance of the [app object](/{{ page.lang }}/5x/api.html#app) by using the `app.use()`and`app.METHOD()`functions, where `METHOD`is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase.
38
38
39
39
Dieses Beispiel zeigt eine Middlewarefunktion ohne Mountpfad. Die Funktion wird immer dann ausgeführt, wenn die Anwendung eine Anforderung erhält.
40
40
@@ -248,9 +248,9 @@ Seit Version 4.x bestehen bei Express keine Abhängigkeiten zu [Connect](https:/
248
248
249
249
Die einzige integrierte Middlewarefunktion in Express ist `express.static`.
250
250
251
-
-[express.static](/en/4x/api.html#express.static) serves static assets such as HTML files, images, and so on.
252
-
-[express.json](/en/4x/api.html#express.json) parses incoming requests with JSON payloads. **NOTE: Available with Express 4.16.0+**
253
-
-[express.urlencoded](/en/4x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+**
251
+
-[express.static](/en/5x/api.html#express.static) serves static assets such as HTML files, images, and so on.
252
+
-[express.json](/en/5x/api.html#express.json) parses incoming requests with JSON payloads. **NOTE: Available with Express 4.16.0+**
253
+
-[express.urlencoded](/en/5x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+**
Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.
12
12
13
-
_Middleware_ functions are functions that have access to the [request object](/{{ page.lang }}/4x/api.html#req) (`req`), the [response object](/{{ page.lang }}/4x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. The next middleware function is commonly denoted by a variable named `next`.
13
+
_Middleware_ functions are functions that have access to the [request object](/{{ page.lang }}/5x/api.html#req) (`req`), the [response object](/{{ page.lang }}/5x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. The next middleware function is commonly denoted by a variable named `next`.
14
14
15
15
Middleware functions can perform the following tasks:
16
16
@@ -34,7 +34,7 @@ You can also load a series of middleware functions together, which creates a sub
Bind application-level middleware to an instance of the [app object](/{{ page.lang }}/4x/api.html#app) by using the `app.use()` and `app.METHOD()` functions, where `METHOD` is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase.
37
+
Bind application-level middleware to an instance of the [app object](/{{ page.lang }}/5x/api.html#app) by using the `app.use()` and `app.METHOD()` functions, where `METHOD` is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase.
38
38
39
39
This example shows a middleware function with no mount path. The function is executed every time the app receives a request.
40
40
@@ -249,9 +249,10 @@ functions that were previously included with Express are now in separate modules
249
249
250
250
Express has the following built-in middleware functions:
251
251
252
-
-[express.static](/en/4x/api.html#express.static) serves static assets such as HTML files, images, and so on.
253
-
-[express.json](/en/4x/api.html#express.json) parses incoming requests with JSON payloads. **NOTE: Available with Express 4.16.0+**
254
-
-[express.urlencoded](/en/4x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+**
252
+
-[express.static](/en/5x/api.html#express.static) serves static assets such as HTML files, images, and so on.
253
+
-[express.json](/en/5x/api.html#express.json) parses incoming requests with JSON payloads. **NOTE: Available with Express 4.16.0+**
254
+
-[express.urlencoded](/en/5x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+**
255
+
gh-pages
255
256
256
257
Here is an example of using the `express.json` middleware with a custom limit:
In Express 5, the `express.static` middleware's `dotfiles` option now defaults to `"ignore"`. This is a change from Express 4, where dotfiles were served by default. As a result, files inside a directory that starts with a dot (`.`), such as `.well-known`, will no longer be accessible and will return a **404 Not Found** error. This can break functionality that depends on serving dot-directories, such as Android App Links, and Apple Universal Links.
476
+
477
+
Example of breaking code:
478
+
479
+
```js
480
+
// v4
481
+
app.use(express.static('public'))
482
+
```
483
+
484
+
After migrating to Express 5, a request to `/.well-known/assetlinks.json` will result in a **404 Not Found**.
485
+
486
+
To fix this, serve specific dot-directories explicitly using the `dotfiles: "allow"` option:
This approach allows you to safely serve only the intended dot-directories while keeping the default secure behavior for other dotfiles, which remain inaccessible.
495
+
472
496
<h3id="app.listen">app.listen</h3>
473
497
474
498
In Express 5, the `app.listen` method will invoke the user-provided callback function (if provided) when the server receives an error event. In Express 4, such errors would be thrown. This change shifts error-handling responsibility to the callback function in Express 5. If there is an error, it will be passed to the callback as an argument.
0 commit comments