Skip to content

Commit

Permalink
(docs) add explanation for fallback page (#1200)
Browse files Browse the repository at this point in the history
* (docs) add explanation for fallback page

* add more explanation to static vs. fallback middleware

---------

Co-authored-by: Elad Kaplan <[email protected]>
  • Loading branch information
jtwaleson and kaplanelad authored Jan 23, 2025
1 parent 4280f92 commit a5421fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs-site/content/blog/frontend-website.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ Now, run the Loco server again and you should see frontend app serving via Loco
$ cargo loco start
```

If you see the default fallback page, you have to disable the fallback middleware. The default fallback takes priority over the static handler, so no static content will be served if it is enabled. You can disable it like so:

```yaml
server:
middlewares:
fallback:
enable: false
static:
...
```
# Developing the UI
Install `react-router-dom`, `react-query` and `axios`
Expand Down
4 changes: 4 additions & 0 deletions docs-site/content/docs/getting-started/starters.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ In your `config/development.yaml`, uncomment the server-side config, and comment
uri: "/static"
path: "assets/static"
fallback: "assets/static/404.html"
fallback:
enable: false
# client side app static config
# static:
# enable: true
Expand All @@ -90,6 +92,8 @@ In your `config/development.yaml`, uncomment the server-side config, and comment
# uri: "/"
# path: "frontend/dist"
# fallback: "frontend/dist/index.html"
# fallback:
# enable: false
```
Expand Down
2 changes: 1 addition & 1 deletion docs-site/content/docs/the-app/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ To disable the middleware edit the configuration as follows:

## Fallback

When choosing the SaaS starter (or any starter that is not API-first), you get a default fallback behavior with the _Loco welcome screen_. This is a development-only mode where a `404` request shows you a nice and friendly page that tells you what happened and what to do next.
When choosing the SaaS starter (or any starter that is not API-first), you get a default fallback behavior with the _Loco welcome screen_. This is a development-only mode where a `404` request shows you a nice and friendly page that tells you what happened and what to do next. This also takes preference over the static handler, so make sure to disable it if you want to have static content served.


You can disable or customize this behavior in your `development.yaml` file. You can set a few options:
Expand Down
9 changes: 8 additions & 1 deletion docs-site/content/docs/the-app/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ In your templates you can refer to static resources in this way:
<img src="/static/image.png"/>
```

However, for the static middleware to work, ensure that the default fallback is disabled:

```yaml
fallback:
enable: false
```
### Customizing the Tera view engine
Expand Down Expand Up @@ -308,4 +315,4 @@ impl Hooks for App {
Loco includes Tera with its [built-ins](https://keats.github.io/tera/docs/#built-ins) functions. In addition, Loco introduces the following custom built-in functions:

To see Loco built-in function:
* [numbers](https://docs.rs/loco-rs/latest/loco_rs/controller/views/tera_builtins/filters/number/index.html)
* [numbers](https://docs.rs/loco-rs/latest/loco_rs/controller/views/tera_builtins/filters/number/index.html)

0 comments on commit a5421fa

Please sign in to comment.