Skip to content

Commit d91092b

Browse files
committed
Fix some links
1 parent d4e7a84 commit d91092b

File tree

12 files changed

+31
-28
lines changed

12 files changed

+31
-28
lines changed

src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enable_flag: "assets_navigation_prefers_asset_serving"
1111
disable_flag: "assets_navigation_has_no_effect"
1212
---
1313

14-
For Workers with [static assets](/workers/static-assets/) and this compatibility flag enabled, navigation requests (requests which have a `Sec-Fetch-Mode: navigate` header) will prefer to be served by our asset-serving logic, even when an exact asset match cannot be found. This is particularly useful for applications which operate in either [Single Page Application (SPA) mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none) or [404 page mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none), as this now means the fallback pages of `200 /index.html` and `404 /404.html` will be served ahead of invoking a Worker script and will therefore avoid incurring a charge.
14+
For Workers with [static assets](/workers/static-assets/) and this compatibility flag enabled, navigation requests (requests which have a `Sec-Fetch-Mode: navigate` header) will prefer to be served by our asset-serving logic, even when an exact asset match cannot be found. This is particularly useful for applications which operate in either [Single Page Application (SPA) mode](/workers/static-assets/routing/single-page-application/) or have [custom 404 pages](/workers/static-assets/routing/static-site-generation/#custom-404-pages), as this now means the fallback pages of `200 /index.html` and `404 /404.html` will be served ahead of invoking a Worker script and will therefore avoid incurring a charge.
1515

1616
Without this flag, the runtime will continue to apply the old behavior of invoking a Worker script (if present) for any requests which do not exactly match a static asset.
1717

src/content/docs/workers/configuration/multipart-upload-metadata.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ At a minimum, the `main_module` key is required to upload a Worker.
4343

4444
* [Asset](/workers/static-assets/) configuration for a Worker.
4545
* `config` <Type text="object" /> <MetaInfo text="optional" />
46-
* [html_handling](/workers/static-assets/routing/#1-html_handling) determines the redirects and rewrites of requests for HTML content.
47-
* [not_found_handling](/workers/static-assets/routing/#2-not_found_handling) determines the response when a request does not match a static asset, and there is no Worker script.
46+
* [html_handling](/workers/static-assets/routing/advanced/html-handling/) determines the redirects and rewrites of requests for HTML content.
47+
* [not_found_handling](/workers/static-assets/routing/) determines the response when a request does not match a static asset.
4848
* `jwt` field provides a token authorizing assets to be attached to a Worker.
4949

5050
* `keep_assets` <Type text="boolean" /> <MetaInfo text="optional" />

src/content/docs/workers/frameworks/framework-guides/astro.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Astro
4-
tags: ["full-stack"]
4+
tags: ["ssg", "full-stack"]
55
description: Create an Astro application and deploy it to Cloudflare Workers with Workers Assets.
66
---
77

@@ -38,7 +38,7 @@ import {
3838

3939
Astro emphasizes performance through minimal client-side JavaScript - by default, it renders as much content as possible at build time, or [on-demand](https://docs.astro.build/en/guides/on-demand-rendering/) on the "server" - this can be a Cloudflare Worker. [“Islands”](https://docs.astro.build/en/concepts/islands/) of JavaScript are added only where interactivity or personalization is needed.
4040

41-
Astro is also framework-agnostic, and supports every major UI framework, including React, Preact, Svelte, Vue, SolidJS , via its official [integrations](https://astro.build/integrations/).
41+
Astro is also framework-agnostic, and supports every major UI framework, including React, Preact, Svelte, Vue, SolidJS, via its official [integrations](https://astro.build/integrations/).
4242

4343
## Deploy a new Astro project on Workers
4444

@@ -96,7 +96,7 @@ If your Astro project is entirely pre-rendered, follow these steps:
9696
</WranglerConfig>
9797
<Details header="What's this configuration doing?">
9898
The key part of this config is the `assets` field, which tells Wrangler where to find your static assets. In this case, we're telling Wrangler to look in the `./dist` directory. If your assets are in a different directory, update the `directory` value accordingly.
99-
Read about other [asset configuration options](/workers/static-assets/routing/).
99+
Read about other [asset configuration options](/workers/wrangler/configuration/#assets).
100100

101101
Also note how there's no `main` field in this config - this is because you're only serving static assets, so no Worker code is needed for on demand rendering/SSR.
102102
</Details>
@@ -161,7 +161,7 @@ If your Astro project uses [on demand rendering (also known as SSR)](https://doc
161161
- `main` points to the entry point of your Worker script. This is generated by the Astro adaptor, and is what powers your server-rendered pages.
162162
- `assets.directory` tells Wrangler where to find your static assets. In this case, we're telling Wrangler to look in the `./dist` directory. If your assets are in a different directory, update the `directory` value accordingly.
163163

164-
Read more about [Wrangler configuration options](/workers/wrangler/configuration/) and [asset configuration options](/workers/static-assets/routing/).
164+
Read more about [Wrangler configuration options](/workers/wrangler/configuration/) and [asset configuration options](/workers/wrangler/configuration/#assets).
165165
</Details>
166166

167167
4. **Build and deploy your project**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Now Wrangler will not upload these files as client-side assets when deploying th
6161

6262
## `run_worker_first`
6363

64-
Controls whether to invoke the Worker script regardless of a request which would have otherwise matched an asset. `run_worker_first = false` ([default](/workers/static-assets/routing/#default-behavior)) will serve any static asset matching a request, while `run_worker_first = true` will unconditionally [invoke your Worker script](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets).
64+
Controls whether to invoke the Worker script regardless of a request which would have otherwise matched an asset. `run_worker_first = false` (default) will serve any static asset matching a request, while `run_worker_first = true` will unconditionally [invoke your Worker script](/workers/static-assets/routing/worker-script/#run-your-worker-script-first).
6565

6666
<WranglerConfig>
6767

@@ -115,7 +115,7 @@ In the example above, assets would be available through `env.ASSETS`.
115115

116116
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

118-
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.
118+
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/) behavior.
119119

120120
<Tabs>
121121
<TabItem label="JavaScript" icon="seti:javascript">
@@ -166,7 +166,7 @@ For the various static asset routing configuration options, refer to [Routing](/
166166

167167
### Smart Placement with Worker Code First
168168

169-
If you desire to run your [Worker code ahead of assets](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets) by setting `run_worker_first=true`, all requests must first travel to your Smart-Placed Worker. As a result, you may experience increased latency for asset requests.
169+
If you desire to run your [Worker code ahead of assets](/workers/static-assets/routing/worker-script/#run-your-worker-script-first) by setting `run_worker_first=true`, all requests must first travel to your Smart-Placed Worker. As a result, you may experience increased latency for asset requests.
170170

171171
Use Smart Placement with `run_worker_first=true` when you need to integrate with other backend services, authenticate requests before serving any assets, or if your want to make modifications to your assets before serving them.
172172

@@ -178,4 +178,4 @@ Enabling Smart Placement with `run_worker_first=false` (or not specifying it) le
178178

179179
Use Smart Placement with `run_worker_first=false` (or not specifying it) when prioritizing fast asset delivery.
180180

181-
This will not impact the [default routing behavior](/workers/static-assets/routing/#default-behavior).
181+
This will not impact the [default routing behavior](/workers/static-assets/routing/).

src/content/docs/workers/static-assets/direct-upload.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ If this is a Worker which already has assets, and you wish to just re-use the ex
177177
}
178178
```
179179

180-
Asset [routing configuration](/workers/static-assets/routing/#routing-configuration) can be provided in the `assets` object, such as `html_handling` and `not_found_handling`.
180+
Asset [routing configuration](/workers/wrangler/configuration/#assets) can be provided in the `assets` object, such as `html_handling` and `not_found_handling`.
181181

182182
```bash title="Example Worker Metadata Specifying Asset Configuration"
183183
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default {
8585

8686
By default, if a requested URL matches a file in the static assets directory, that file will always be served — without running Worker code. If no matching asset is found and a Worker is configured, the request will be processed by the Worker instead.
8787

88-
- If no Worker is set up, the [`not_found_handling`](/workers/static-assets/routing/#2-not_found_handling-1) setting in your Wrangler configuration determines what happens next. By default, a `404 Not Found` response is returned.
88+
- If no Worker is set up, the [`not_found_handling`](/workers/static-assets/routing/) setting in your Wrangler configuration determines what happens next. By default, a `404 Not Found` response is returned.
8989

9090
- If a Worker is configured and a request does not match a static asset, the Worker will handle the request. The Worker can choose to pass the request to the asset binding (through `env.ASSETS.fetch()`), following the `not_found_handling` rules.
9191

@@ -117,7 +117,7 @@ If you want the Worker code to execute before serving an asset (for example, to
117117

118118
<LinkCard
119119
title="Routing options"
120-
href="/workers/static-assets/routing/#routing-configuration"
120+
href="/workers/static-assets/routing/"
121121
description="Learn more about how you can customize routing behavior."
122122
/>
123123

src/content/docs/workers/static-assets/migrations/migrate-from-pages.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Once the Worker script has been compiled, you can update your configuration file
193193

194194
If you authored [a `_routes.json` file](/pages/functions/routing/#create-a-_routesjson-file) in your Pages project, or used [middleware](/pages/functions/middleware/) in Pages Functions, you must pay close attention to the configuration of your Worker script. Pages would default to serving your Pages Functions ahead of static assets and `_routes.json` and Pages Functions middleware allowed you to customize this behavior.
195195

196-
Workers, on the other hand, will default to serving static assets ahead of your Worker script, unless you have configured [`assets.run_worker_first`](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets). This option is required if you are, for example, performing any authentication checks or logging requests before serving static assets.
196+
Workers, on the other hand, will default to serving static assets ahead of your Worker script, unless you have configured [`assets.run_worker_first`](/workers/static-assets/routing/worker-script/#run-your-worker-script-first). This option is required if you are, for example, performing any authentication checks or logging requests before serving static assets.
197197

198198
<WranglerConfig>
199199

@@ -400,7 +400,7 @@ This compatibility matrix compares the features of Workers and Pages. Unless oth
400400
| [Middleware](/workers/static-assets/binding/#run_worker_first) |[^1] ||
401401
| [Redirects](/workers/static-assets/redirects/) |||
402402
| [Smart Placement](/workers/configuration/smart-placement/) |||
403-
| [Serve assets on a path](/workers/static-assets/routing/) |||
403+
| [Serve assets on a path](/workers/static-assets/routing/advanced/serving-a-subdirectory/) |||
404404
| **Observability** | | |
405405
| [Workers Logs](/workers/observability/) |||
406406
| [Logpush](/workers/observability/logs/logpush/) |||

src/content/docs/workers/static-assets/routing/server-side-generated.mdx renamed to src/content/docs/workers/static-assets/routing/static-site-generation.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: concept
3-
title: Static-Site Generation (SSG) application
4-
description: How to configure and use a Static Site Generation (SSG) application with Workers.
3+
title: Static Site Generation (SSG) and custom 404 pages
4+
description: How to configure a Static Site Generation (SSG) application and custom 404 pages with Workers.
55
sidebar:
66
order: 3
77
---
@@ -32,10 +32,12 @@ In order to deploy a Static Site Generation application to Workers, you must con
3232

3333
</WranglerConfig>
3434

35-
Configuring `assets.not_found_handling` to `404-page` overrides the default serving behavior of Workers for static assets. When an incoming request does not match a file in the `assets.directory`, Workers will serve the contents of the nearest `404.html` file with a `404 Not Found` status.
36-
3735
`assets.html_handling` defaults to `auto-trailing-slash` and this will usually give you the desired behavior automatically: individual files (e.g. `foo.html`) will be served _without_ a trailing flash and folder index files (e.g. `foo/index.html`) will be served _with_ a trailing slash. Alternatively, you can force trailing slashes (`force-trailing-slash`) or drop trailing slashes (`drop-trailing-slash`) on requests for HTML pages.
3836

37+
### Custom 404 pages
38+
39+
Configuring `assets.not_found_handling` to `404-page` overrides the default serving behavior of Workers for static assets. When an incoming request does not match a file in the `assets.directory`, Workers will serve the contents of the nearest `404.html` file with a `404 Not Found` status.
40+
3941
<Render file="navigation_requests" />
4042

4143
## Local Development

src/content/docs/workers/vite-plugin/reference/static-assets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ On running `vite build`, an output `wrangler.json` configuration file is generat
2121
The `assets.directory` field in this file is automatically populated with the path to your `client` build output.
2222
It is therefore not necessary to provide the `assets.directory` field in your input Worker configuration.
2323

24-
The `assets` configuration should be used, however, if you wish to set [routing configuration](/workers/static-assets/routing/#routing-configuration) or enable the [assets binding](/workers/static-assets/binding/#binding).
24+
The `assets` configuration should be used, however, if you wish to set [routing configuration](/workers/static-assets/routing/) or enable the [assets binding](/workers/static-assets/binding/#binding).
2525
The following example configures the `not_found_handling` for a single-page application so that the fallback will always be the root `index.html` file.
2626

2727
<WranglerConfig>

src/content/docs/workers/vite-plugin/tutorial.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ assets = { not_found_handling = "single-page-application" }
6868

6969
</WranglerConfig>
7070

71-
The [`not_found_handling`](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none) value has been set to `single-page-application`.
71+
The [`not_found_handling`](/workers/single-page-application/) value has been set to `single-page-application`.
7272
This means that all not found requests will serve the `index.html` file.
7373
With the Cloudflare plugin, the `assets` routing configuration is used in place of Vite's default behavior.
74-
This ensures that your application's [routing configuration](/workers/static-assets/routing/#routing-configuration) works the same way while developing as it does when deployed to production.
74+
This ensures that your application's [routing configuration](/workers/static-assets/routing/) works the same way while developing as it does when deployed to production.
7575

7676
Note that the [`directory`](/workers/static-assets/binding/#directory) field is not used when configuring assets with Vite.
7777
The `directory` in the output configuration will automatically point to the client build output.

0 commit comments

Comments
 (0)