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
Copy file name to clipboardExpand all lines: src/content/docs/workers/static-assets/routing.mdx
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,14 +219,15 @@ Take the following directory structure:
219
219
/folder/doesnt/exist -> 200 /index.html
220
220
```
221
221
222
-
## Mounting assets on a path
222
+
## Serving assets from a custom path
223
223
224
224
:::note
225
225
This feature requires Wrangler v3.xx.xx or later.
226
226
:::
227
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.
228
+
Like with any other Worker, [you can configure a Worker with assets to run on a subpath of your domain](https://developers.cloudflare.com/workers/configuration/routing/routes/). Assets in such a Worker such be nested in a directory structure that mirrors the desired path.
229
+
230
+
For example, to serve assets from `example.com/blog/*`, create a `blog` directory in your asset directory.
230
231
231
232
<FileTree>
232
233
- dist
@@ -240,7 +241,7 @@ For example, to serve assets from `example.com/blog`, create a `blog` directory
240
241
With a Wrangler configuration file like so:
241
242
<WranglerConfig>
242
243
```toml
243
-
name = "mounted-assets-example"
244
+
name = "assets-on-a-path-example"
244
245
main = "src/index.js"
245
246
route = "example.com/blog/*"
246
247
@@ -249,6 +250,6 @@ directory = "dist"
249
250
```
250
251
</WranglerConfig>
251
252
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
+
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
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`.
255
+
If you have a file outside the configured 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`. However, if needed, these files can still be manually fetched over [the binding](https://developers.cloudflare.com/workers/static-assets/binding/#binding).
0 commit comments