Skip to content

Commit e194027

Browse files
committed
Mounted assets docs
1 parent 2708df3 commit e194027

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ public/_redirects
66
public/analytics/static/downloads/main.css
77
src/content/workers-ai-models/*.json
88
tests/fixtures/openapi.json
9+
**/*.mdx

src/content/docs/workers/static-assets/routing.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,37 @@ Take the following directory structure:
218218
/not-found -> 200 /index.html
219219
/folder/doesnt/exist -> 200 /index.html
220220
```
221+
222+
## Mounting assets on a path
223+
224+
:::note
225+
This feature requires Wrangler v3.xx.xx or later.
226+
:::
227+
228+
You can mount assets on a path by creating a directory structure that mirrors the desired path.
229+
For example, to serve assets from `example.com/blog`, create a `blog` directory in your asset directory.
230+
231+
<FileTree>
232+
- dist
233+
- blog
234+
- index.html
235+
- posts
236+
- post1.html
237+
- post2.html
238+
</FileTree>
239+
240+
With a Wrangler configuration file like so:
241+
<WranglerConfig>
242+
```toml
243+
name = "mounted-assets-example"
244+
main = "src/index.js"
245+
route = "example.com/blog/*"
246+
247+
[assets]
248+
directory = "dist"
249+
```
250+
</WranglerConfig>
251+
252+
In this example, requests to `example.com/blog` will serve the `index.html` file, and requests to `example.com/blog/posts/post1` will serve the `post1.html` file.
253+
254+
If you have a file outside the mounted path, it will not be served. For example, if you have a `home.html` file in the root of your asset directory, it will not be served when requesting `example.com/blog/home`.

0 commit comments

Comments
 (0)