Skip to content

Commit fbaaa76

Browse files
authored
docs(static-files): add a dedicated section for specifying a default document (#1906)
1 parent a7a5bf2 commit fbaaa76

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

docs/package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/content/docs/basics/static-files.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
8383
In the above example, we're using `api/static` as our static file directory but
8484
you can specify a path to any directory for Dart Frog to use.
8585

86+
## Specifying a Default Document 📄
87+
88+
:::note
89+
90+
Specifying a `defaultDocument` requires `dart_frog ^1.2.5`.
91+
92+
:::
93+
8694
You can also configure the default document by specifying the `defaultDocument`
8795
parameter when creating the `createStaticFileHandler` handler.
8896

@@ -92,13 +100,12 @@ import 'dart:io';
92100
import 'package:dart_frog/dart_frog.dart';
93101
94102
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
95-
const customStaticFilePath = 'api/static';
96103
final cascade = Cascade()
97-
.add(createStaticFileHandler(path: customStaticFilePath, defaultDocument: 'index.html'))
104+
.add(createStaticFileHandler(defaultDocument: 'index.html'))
98105
.add(handler);
99106
return serve(cascade.handler, ip, port);
100107
}
101108
```
102109

103110
In this example, requests made to the root of the server will serve the
104-
`index.html` file.
111+
`index.html` file located in the `public` directory.

0 commit comments

Comments
 (0)