Skip to content

Commit 0fbad3b

Browse files
authored
docs: improve historyApiFallback example (#3759)
1 parent 79e4bd7 commit 0fbad3b

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

examples/history-api-fallback/README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,41 @@ Usage via CLI:
2121
npx webpack serve --open --history-api-fallback
2222
```
2323

24-
_Note: some URLs don't work by default. For example; if the url contains a dot.
24+
## What Should Happen
25+
26+
1. The script should open `http://0.0.0.0:8080/` in your default browser.
27+
2. You should see text on the page that reads `Current Path: /`.
28+
3. Navigate to `http://localhost:8080/foo-bar`.
29+
4. You should see text on the page that reads `Current Path: /foo-bar`.
30+
31+
_Note: some URLs don't work by default. For example, if the url contains a dot (`/file.txt` in this example).
2532
Be sure to checkout the [connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback)
2633
options._
2734

35+
To allow `/file.txt` to fallback, update the `webpack.config.js` as follows:
36+
37+
**webpack.config.js**
38+
39+
```js
40+
module.exports = {
41+
// ...
42+
devServer: {
43+
historyApiFallback: {
44+
disableDotRule: true,
45+
},
46+
},
47+
};
48+
```
49+
50+
Usage via CLI:
51+
52+
```console
53+
npx webpack serve --open
54+
```
55+
2856
## What Should Happen
2957

3058
1. The script should open `http://0.0.0.0:8080/` in your default browser.
31-
2. You should see text on the page that reads 'Current Path: /'.
32-
3. Navigate to `http://localhost:8080/foo/bar`.
33-
4. You should see text on the page that reads 'Current Path: /foo/background'.
59+
2. You should see text on the page that reads `Current Path: /`.
60+
3. Navigate to `http://localhost:8080/file.txt`.
61+
4. You should see text on the page that reads `Current Path: /file.txt`.

examples/history-api-fallback/webpack.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module.exports = setup({
88
context: __dirname,
99
entry: "./app.js",
1010
devServer: {
11-
historyApiFallback: {
12-
disableDotRule: true,
13-
},
11+
historyApiFallback: true,
1412
},
1513
});

0 commit comments

Comments
 (0)