Skip to content

Commit f76386f

Browse files
Update Workers Assets request param to include strings and urls (#20342)
* Update Workers Assets request param to include strings and urls * Update src/content/docs/workers/static-assets/binding.mdx Co-authored-by: Daniel Walsh <[email protected]> --------- Co-authored-by: Daniel Walsh <[email protected]>
1 parent f8fd0b7 commit f76386f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
Render,
1616
TabItem,
1717
Tabs,
18-
WranglerConfig
18+
WranglerConfig,
1919
} from "~/components";
2020

2121
Configuring a Worker with assets requires specifying a [directory](/workers/static-assets/binding/#directory) and, optionally, an [assets binding](/workers/static-assets/binding/), in your Worker's Wrangler file. The [assets binding](/workers/static-assets/binding/) allows you to dynamically fetch assets from within your Worker script (e.g. `env.ASSETS.fetch()`), similarly to how you might with a make a `fetch()` call with a [Service binding](/workers/runtime-apis/bindings/service-bindings/http/).
@@ -105,15 +105,15 @@ In the example above, assets would be available through `env.ASSETS`.
105105

106106
**Parameters**
107107

108-
- `request: Request` Pass a [Request object](/workers/runtime-apis/request/), URL string, or URL object. Requests made through this method have `html_handling` and `not_found_handling` configuration applied to them.
108+
- `request: Request | URL | string` Pass a [Request object](/workers/runtime-apis/request/), URL object, or URL string. Requests made through this method have `html_handling` and `not_found_handling` configuration applied to them.
109109

110110
**Response**
111111

112112
- `Promise<Response>` Returns a static asset response for the given request.
113113

114114
**Example**
115115

116-
Your dynamic code can make new, or forward incoming, requests to your project's static assets using the assets binding.
116+
Your dynamic code can make new, or forward incoming requests to your project's static assets using the assets binding. For example, `env.ASSETS.fetch(request)`, `env.ASSETS.fetch(new URL('https://assets.local/my-file'))` or `env.ASSETS.fetch('https://assets.local/my-file')`.
117117

118118
Take the following example that configures a Worker script to return a response under all requests headed for `/api/`. Otherwise, the Worker script will pass the incoming request through to the asset binding. In this case, because a Worker script is only invoked when the requested route has not matched any static assets, this will always evaluate [`not_found_handling`](/workers/static-assets/routing/#routing-configuration) behavior.
119119

0 commit comments

Comments
 (0)