Skip to content

Commit 6eb5f7e

Browse files
authored
Update Assets syntax to more standardised table (#18919)
1 parent 91edf3b commit 6eb5f7e

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ compatibility_date = "2024-09-19"
7272
main = "src/index.ts"
7373
# The following configuration unconditionally invokes the Worker script at
7474
# `src/index.ts`, which can programatically fetch assets via the ASSETS binding
75-
assets = { directory = "./public/", binding = "ASSETS", experimental_serve_directly = false }
75+
[assets]
76+
directory = "./public/"
77+
binding = "ASSETS"
78+
experimental_serve_directly = false
7679
```
7780

7881
</WranglerConfig>
@@ -88,7 +91,9 @@ name = "my-worker"
8891
main = "./src/index.js"
8992
compatibility_date = "2024-09-19"
9093

91-
assets = { directory = "./public/", binding = "ASSETS" }
94+
[assets]
95+
directory = "./public/"
96+
binding = "ASSETS"
9297
```
9398

9499
</WranglerConfig>
@@ -113,8 +118,8 @@ Your dynamic code can make new, or forward incoming, requests to your project's
113118

114119
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.
115120

116-
<Tabs> <TabItem label="JavaScript" icon="seti:javascript">
117-
121+
<Tabs>
122+
<TabItem label="JavaScript" icon="seti:javascript">
118123
```js
119124
export default {
120125
async fetch(request, env) {
@@ -129,9 +134,8 @@ export default {
129134
},
130135
};
131136
```
132-
133-
</TabItem> <TabItem label="TypeScript" icon="seti:typescript">
134-
137+
</TabItem>
138+
<TabItem label="TypeScript" icon="seti:typescript">
135139
```ts
136140
interface Env {
137141
ASSETS: Fetcher;
@@ -150,8 +154,8 @@ export default {
150154
},
151155
} satisfies ExportedHandler<Env>;
152156
```
153-
154-
</TabItem> </Tabs>
157+
</TabItem>
158+
</Tabs>
155159

156160
## Routing configuration
157161

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ Requests to a project with static assets can either return static assets or invo
6767

6868
**Requests to static assets are free and unlimited**. Requests to the Worker script (e.g. in the case of SSR content) are billed according to Workers pricing. Refer to [pricing](/workers/platform/pricing/#example-2) for an example.
6969

70-
There's no additional cost for storing Assets.
70+
There's no additional cost for storing Assets.
7171

7272
### Troubleshooting
7373

74-
- `assets.bucket is a required field` if you see this error, you need to update Wrangler to at least `3.78.10` or later. `bucket` is not a required field.
74+
- `assets.bucket is a required field` if you see this error, you need to update Wrangler to at least `3.78.10` or later. `bucket` is not a required field.
7575

7676
### Limitations
7777

7878
The following limitations apply for Workers with static assets:
7979

80-
- There is a 20,000 file count limit per [Worker version](/workers/configuration/versions-and-deployments/), and a 25 MiB individual file size limit. This matches the [limits in Cloudflare Pages](/pages/platform/limits/) today.
80+
- There is a 20,000 file count limit per [Worker version](/workers/configuration/versions-and-deployments/), and a 25 MiB individual file size limit. This matches the [limits in Cloudflare Pages](/pages/platform/limits/) today.
8181
- You cannot upload static assets to [Workers for Platforms](/cloudflare-for-platforms/workers-for-platforms/) [user workers](/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/). This is a temporary limitation, we are working to remove it.
8282
- In local development, you cannot make [Service Binding RPC calls](/workers/runtime-apis/bindings/service-bindings/rpc/) to a Worker with static assets. This is a temporary limitation, we are working to remove it.
8383
- Workers with assets cannot run on a [route or domain](/workers/configuration/routing/) with a path component. For example, `example.com/*` is an acceptable route, but `example.com/foo/*` is not. Wrangler and the Cloudflare dashboard will throw an error when you try and add a route with a path component.

0 commit comments

Comments
 (0)