From fa6af91ab5a26692d9095eec1bd50a51bf3e60fe Mon Sep 17 00:00:00 2001 From: lrapoport-cf Date: Mon, 5 May 2025 16:22:48 -0400 Subject: [PATCH 1/7] Fix typos --- .../docs/workers/frameworks/framework-guides/react.mdx | 2 +- .../workers/static-assets/routing/advanced/html-handling.mdx | 2 +- .../workers/static-assets/routing/static-site-generation.mdx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/frameworks/framework-guides/react.mdx b/src/content/docs/workers/frameworks/framework-guides/react.mdx index 75f4698e42fb5c8..66b8404e766cf84 100644 --- a/src/content/docs/workers/frameworks/framework-guides/react.mdx +++ b/src/content/docs/workers/frameworks/framework-guides/react.mdx @@ -25,7 +25,7 @@ import { /> --- -**Or just deploy** - create a full-stack app using React, Hono API And Vite, with CI/CD and previews all set up for you. +**Or just deploy** - create a full-stack app using React, Hono API and Vite, with CI/CD and previews all set up for you. [![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/templates/tree/staging/vite-react-template) diff --git a/src/content/docs/workers/static-assets/routing/advanced/html-handling.mdx b/src/content/docs/workers/static-assets/routing/advanced/html-handling.mdx index b058cd572d237eb..0589efc47a7257e 100644 --- a/src/content/docs/workers/static-assets/routing/advanced/html-handling.mdx +++ b/src/content/docs/workers/static-assets/routing/advanced/html-handling.mdx @@ -23,7 +23,7 @@ Take the following directory structure: ## Automatic trailing slashes (default) -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. +This will usually give you the desired behavior automatically: individual files (e.g. `foo.html`) will be served _without_ a trailing slash and folder index files (e.g. `foo/index.html`) will be served _with_ a trailing slash. diff --git a/src/content/docs/workers/static-assets/routing/static-site-generation.mdx b/src/content/docs/workers/static-assets/routing/static-site-generation.mdx index 2ba31e2cdfe2577..cdb947eebe7d589 100644 --- a/src/content/docs/workers/static-assets/routing/static-site-generation.mdx +++ b/src/content/docs/workers/static-assets/routing/static-site-generation.mdx @@ -8,7 +8,7 @@ sidebar: import { WranglerConfig, Render } from "~/components"; -Static Site Generation (SSG) applications are web applications which are predominantely built or "prerendered" ahead-of-time. They are often built with a framework such as [Gatsby](/workers/frameworks/framework-guides/gatsby/) or [Docusaurus](/workers/frameworks/framework-guides/docusaurus/). The build process of these frameworks will produce a many HTML files and accompanying client-side resources (e.g. JavaScript bundles, CSS stylesheets, images, fonts, etc.). Data is either static, fetched and compiled into the HTML at build-time, or fetched by the client from an API with client-side requests. +Static Site Generation (SSG) applications are web applications which are predominantely built or "prerendered" ahead-of-time. They are often built with a framework such as [Gatsby](/workers/frameworks/framework-guides/gatsby/) or [Docusaurus](/workers/frameworks/framework-guides/docusaurus/). The build process of these frameworks will produce many HTML files and accompanying client-side resources (e.g. JavaScript bundles, CSS stylesheets, images, fonts, etc.). Data is either static, fetched and compiled into the HTML at build-time, or fetched by the client from an API with client-side requests. Often, an SSG framework will allow you to create a custom 404 page. @@ -32,7 +32,7 @@ In order to deploy a Static Site Generation application to Workers, you must con -`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. +`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 slash 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. ### Custom 404 pages From 39ffbd9b27bd7189ee2be22ae0c33b0859d201b0 Mon Sep 17 00:00:00 2001 From: lrapoport-cf Date: Wed, 7 May 2025 16:25:46 -0400 Subject: [PATCH 2/7] Update links for routing behavior and not_found_handling. --- src/content/docs/workers/static-assets/binding.mdx | 4 ++-- src/content/docs/workers/static-assets/index.mdx | 2 +- src/content/docs/workers/wrangler/configuration.mdx | 6 +++--- .../partials/workers/workers-assets-routing-summary.mdx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/docs/workers/static-assets/binding.mdx b/src/content/docs/workers/static-assets/binding.mdx index f37472854e5cda1..8cace3addee9171 100644 --- a/src/content/docs/workers/static-assets/binding.mdx +++ b/src/content/docs/workers/static-assets/binding.mdx @@ -115,7 +115,7 @@ In the example above, assets would be available through `env.ASSETS`. 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')`. -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. +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) behavior. @@ -178,4 +178,4 @@ Enabling Smart Placement with `run_worker_first=false` (or not specifying it) le Use Smart Placement with `run_worker_first=false` (or not specifying it) when prioritizing fast asset delivery. -This will not impact the [default routing behavior](/workers/static-assets/routing/). +This will not impact the [default routing behavior](/workers/static-assets/#routing-behavior). diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index d575c32233d67b1..1d412b7c4a93562 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -85,7 +85,7 @@ export default { 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. -- 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. +- If no Worker is set up, the [`not_found_handling`](/workers/static-assets/#routing-behavior) setting in your Wrangler configuration determines what happens next. By default, a `404 Not Found` response is returned. - 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. diff --git a/src/content/docs/workers/wrangler/configuration.mdx b/src/content/docs/workers/wrangler/configuration.mdx index d463330c3cfdae2..77ef7c7c256b3a9 100644 --- a/src/content/docs/workers/wrangler/configuration.mdx +++ b/src/content/docs/workers/wrangler/configuration.mdx @@ -694,8 +694,8 @@ To bind Images to your Worker, assign an array of the below object to the `image ```jsonc { "images": { - "binding": "IMAGES", // i.e. available in your Worker on env.IMAGES - }, + "binding": "IMAGES" // i.e. available in your Worker on env.IMAGES + } } ``` @@ -1037,7 +1037,7 @@ The following options are available under the `assets` key. - `not_found_handling`: - - Determines the handling of requests that do not map to an asset. Learn more about the various options in [assets routing](/workers/static-assets/routing/). + - Determines the handling of requests that do not map to an asset. Learn more about the various options for [routing behavior](/workers/static-assets/#routing-behavior). Example: diff --git a/src/content/partials/workers/workers-assets-routing-summary.mdx b/src/content/partials/workers/workers-assets-routing-summary.mdx index d30823f56410a70..1ad15be8bd9d312 100644 --- a/src/content/partials/workers/workers-assets-routing-summary.mdx +++ b/src/content/partials/workers/workers-assets-routing-summary.mdx @@ -2,6 +2,6 @@ {} --- -By default, Cloudflare first tries to match a request path against a static asset path, which is based on the file structure of the uploaded asset directory. This is either the directory specified by `assets.directory` in your Wrangler config or, in the case of the [Cloudflare Vite plugin](/workers/vite-plugin/), the output directory of the client build. Failing that, we invoke a Worker if one is present. If there is no Worker, or the Worker then uses the asset binding, Cloudflare will fallback to the behaviour set by [`not_found_handling`](/workers/static-assets/routing/). +By default, Cloudflare first tries to match a request path against a static asset path, which is based on the file structure of the uploaded asset directory. This is either the directory specified by `assets.directory` in your Wrangler config or, in the case of the [Cloudflare Vite plugin](/workers/vite-plugin/), the output directory of the client build. Failing that, we invoke a Worker if one is present. If there is no Worker, or the Worker then uses the asset binding, Cloudflare will fallback to the behaviour set by [`not_found_handling`](/workers/static-assets/#routing-behavior). Refer to the [routing documentation](/workers/static-assets/routing/) for more information about how routing works with static assets, and how to customize this behavior. From cf6994843d892002bd5f0d4c77b432165da16732 Mon Sep 17 00:00:00 2001 From: lrapoport-cf Date: Wed, 7 May 2025 21:04:37 -0400 Subject: [PATCH 3/7] Update link for not_found_handling and formatting auto-fixes --- .../multipart-upload-metadata.mdx | 258 +++++++++--------- 1 file changed, 123 insertions(+), 135 deletions(-) diff --git a/src/content/docs/workers/configuration/multipart-upload-metadata.mdx b/src/content/docs/workers/configuration/multipart-upload-metadata.mdx index 307bf3cb0b9c620..b95292f489e9236 100644 --- a/src/content/docs/workers/configuration/multipart-upload-metadata.mdx +++ b/src/content/docs/workers/configuration/multipart-upload-metadata.mdx @@ -1,7 +1,6 @@ --- pcx_content_type: concept title: Multipart upload metadata - --- import { Type, MetaInfo } from "~/components"; @@ -12,15 +11,15 @@ If you're using the [Workers Script Upload API](/api/resources/workers/subresour ```json { - "main_module": "main.js", - "bindings": [ - { - "type": "plain_text", - "name": "MESSAGE", - "text": "Hello, world!" - } - ], - "compatibility_date": "2021-09-14" + "main_module": "main.js", + "bindings": [ + { + "type": "plain_text", + "name": "MESSAGE", + "text": "Hello, world!" + } + ], + "compatibility_date": "2021-09-14" } ``` @@ -33,41 +32,38 @@ The following attributes are configurable at the top-level. At a minimum, the `main_module` key is required to upload a Worker. ::: +- `main_module` + - The part name that contains the module entry point of the Worker that will be executed. For example, `main.js`. -* `main_module` - - * The part name that contains the module entry point of the Worker that will be executed. For example, `main.js`. - -* `assets` +- `assets` - * [Asset](/workers/static-assets/) configuration for a Worker. - * `config` - * [html_handling](/workers/static-assets/routing/advanced/html-handling/) determines the redirects and rewrites of requests for HTML content. - * [not_found_handling](/workers/static-assets/routing/) determines the response when a request does not match a static asset. - * `jwt` field provides a token authorizing assets to be attached to a Worker. + - [Asset](/workers/static-assets/) configuration for a Worker. + - `config` + - [html_handling](/workers/static-assets/routing/advanced/html-handling/) determines the redirects and rewrites of requests for HTML content. + - [not_found_handling](/workers/static-assets/#routing-behavior) determines the response when a request does not match a static asset. + - `jwt` field provides a token authorizing assets to be attached to a Worker. -* `keep_assets` +- `keep_assets` - * Specifies whether assets should be retained from a previously uploaded Worker version; used in lieu of providing a completion token. + - Specifies whether assets should be retained from a previously uploaded Worker version; used in lieu of providing a completion token. -* `bindings` array\[object] optional +- `bindings` array\[object] optional - * [Bindings](#bindings) to expose in the Worker. + - [Bindings](#bindings) to expose in the Worker. -* `placement` +- `placement` - * [Smart placement](/workers/configuration/smart-placement/) object for the Worker. - * `mode` field only supports `smart` for automatic placement. + - [Smart placement](/workers/configuration/smart-placement/) object for the Worker. + - `mode` field only supports `smart` for automatic placement. -* `compatibility_date` +- `compatibility_date` - * [Compatibility Date](/workers/configuration/compatibility-dates/#setting-compatibility-date) indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. Highly recommended to set a `compatibility_date`, otherwise if on upload via the API, it defaults to the oldest compatibility date before any flags took effect (2021-11-02). + - [Compatibility Date](/workers/configuration/compatibility-dates/#setting-compatibility-date) indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. Highly recommended to set a `compatibility_date`, otherwise if on upload via the API, it defaults to the oldest compatibility date before any flags took effect (2021-11-02). -* `compatibility_flags` array\[string] optional - - * [Compatibility Flags](/workers/configuration/compatibility-flags/#setting-compatibility-flags) that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`. +- `compatibility_flags` array\[string] optional + - [Compatibility Flags](/workers/configuration/compatibility-flags/#setting-compatibility-flags) that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`. ## Additional attributes: [Workers Script Upload API](/api/resources/workers/subresources/scripts/methods/update/) @@ -78,25 +74,21 @@ For [immediately deployed uploads](/workers/configuration/versions-and-deploymen These attributes are **not available** for version uploads. ::: +- `migrations` array\[object] optional + - [Durable Objects migrations](/durable-objects/reference/durable-objects-migrations/) to apply. -* `migrations` array\[object] optional - - * [Durable Objects migrations](/durable-objects/reference/durable-objects-migrations/) to apply. - -* `logpush` +- `logpush` - * Whether [Logpush](/cloudflare-for-platforms/cloudflare-for-saas/hostname-analytics/#logpush) is turned on for the Worker. + - Whether [Logpush](/cloudflare-for-platforms/cloudflare-for-saas/hostname-analytics/#logpush) is turned on for the Worker. -* `tail_consumers` array\[object] optional +- `tail_consumers` array\[object] optional - * [Tail Workers](/workers/observability/logs/tail-workers/) that will consume logs from the attached Worker. - -* `tags` array\[string] optional - - * List of strings to use as tags for this Worker. + - [Tail Workers](/workers/observability/logs/tail-workers/) that will consume logs from the attached Worker. +- `tags` array\[string] optional + - List of strings to use as tags for this Worker. ## Additional attributes: [Version Upload API](/api/resources/workers/subresources/scripts/subresources/versions/methods/create/) @@ -107,15 +99,11 @@ For [version uploads](/workers/configuration/versions-and-deployments/#upload-a- These attributes are **not available** for immediately deployed uploads. ::: +- `annotations` - -* `annotations` - - * Annotations object specific to the Worker version. - * `workers/message` specifies a custom message for the version. - * `workers/tag` specifies a custom identifier for the version. - - + - Annotations object specific to the Worker version. + - `workers/message` specifies a custom message for the version. + - `workers/tag` specifies a custom identifier for the version. ## Bindings @@ -123,88 +111,88 @@ Workers can interact with resources on the Cloudflare Developer Platform using [ ```json { - "bindings": [ - { - "type": "ai", - "name": "" - }, - { - "type": "analytics_engine", - "name": "", - "dataset": "" - }, - { - "type": "assets", - "name": "" - }, - { - "type": "browser_rendering", - "name": "" - }, - { - "type": "d1", - "name": "", - "id": "" - }, - { - "type": "durable_object_namespace", - "name": "", - "class_name": "" - }, - { - "type": "hyperdrive", - "name": "", - "id": "" - }, - { - "type": "kv_namespace", - "name": "", - "namespace_id": "" - }, - { - "type": "mtls_certificate", - "name": "", - "certificate_id": "" - }, - { - "type": "plain_text", - "name": "", - "text": "" - }, - { - "type": "queue", - "name": "", - "queue_name": "" - }, - { - "type": "r2_bucket", - "name": "", - "bucket_name": "" - }, - { - "type": "secret_text", - "name": "", - "text": "" - }, - { - "type": "service", - "name": "", - "service": "", - "environment": "production" - }, - { - "type": "tail_consumer", - "service": "" - }, - { - "type": "vectorize", - "name": "", - "index_name": "" - }, - { - "type": "version_metadata", - "name": "" - } - ] + "bindings": [ + { + "type": "ai", + "name": "" + }, + { + "type": "analytics_engine", + "name": "", + "dataset": "" + }, + { + "type": "assets", + "name": "" + }, + { + "type": "browser_rendering", + "name": "" + }, + { + "type": "d1", + "name": "", + "id": "" + }, + { + "type": "durable_object_namespace", + "name": "", + "class_name": "" + }, + { + "type": "hyperdrive", + "name": "", + "id": "" + }, + { + "type": "kv_namespace", + "name": "", + "namespace_id": "" + }, + { + "type": "mtls_certificate", + "name": "", + "certificate_id": "" + }, + { + "type": "plain_text", + "name": "", + "text": "" + }, + { + "type": "queue", + "name": "", + "queue_name": "" + }, + { + "type": "r2_bucket", + "name": "", + "bucket_name": "" + }, + { + "type": "secret_text", + "name": "", + "text": "" + }, + { + "type": "service", + "name": "", + "service": "", + "environment": "production" + }, + { + "type": "tail_consumer", + "service": "" + }, + { + "type": "vectorize", + "name": "", + "index_name": "" + }, + { + "type": "version_metadata", + "name": "" + } + ] } ``` From bcae88583296317e4569f02bf96351e6d4e54c6c Mon Sep 17 00:00:00 2001 From: lrapoport-cf Date: Wed, 7 May 2025 21:24:56 -0400 Subject: [PATCH 4/7] Update routing behavior section --- src/content/docs/workers/static-assets/index.mdx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index 1d412b7c4a93562..70c58efc6f8bb6f 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -83,13 +83,12 @@ export default { ### Routing behavior -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. +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. The Worker can choose to pass the request to the asset binding (through `env.ASSETS.fetch()`). If no worker is set up, a `404 Not Found` response is returned. -- If no Worker is set up, the [`not_found_handling`](/workers/static-assets/#routing-behavior) setting in your Wrangler configuration determines what happens next. By default, a `404 Not Found` response is returned. +The default behavior when neither an asset nor a Worker is found can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration: -- 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. - -You can configure and override this default routing behaviour. For example, if you have a Single Page Application and want to serve `index.html` for all unmatched routes, you can set `not_found_handling = "single-page-application"`: +- `not_found_handling = "single-page-application"`: Sets your application to return `index.html` for unmatched routes. Use this if you have a Single Page Application. +- `not_found_handling = "404-page""`: Sets your application to return `404.html` for unmatched routes. From 9cfe963056bdfea06836fb31e34e478580d1393f Mon Sep 17 00:00:00 2001 From: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com> Date: Thu, 8 May 2025 14:16:06 -0400 Subject: [PATCH 5/7] Update src/content/docs/workers/static-assets/index.mdx Co-authored-by: Greg Brimble --- src/content/docs/workers/static-assets/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index 70c58efc6f8bb6f..07e08bda40d3322 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -83,7 +83,7 @@ export default { ### Routing behavior -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. The Worker can choose to pass the request to the asset binding (through `env.ASSETS.fetch()`). If no worker is set up, a `404 Not Found` response is returned. +By default, if a requested URL matches a file in the static assets directory, that file will be served — without invoking Worker code. If no matching asset is found and a Worker script is present, the request will be processed by the Worker. The Worker can return a response or choose to defer again to static assets by using the [assets binding](/workers/static-assets/binding/) (e.g. `env.ASSETS.fetch(request)`). If no Worker script is present, a `404 Not Found` response is returned. The default behavior when neither an asset nor a Worker is found can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration: From c81269e705d11f2a2b45240ca9de12a3885fa617 Mon Sep 17 00:00:00 2001 From: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com> Date: Thu, 8 May 2025 14:18:44 -0400 Subject: [PATCH 6/7] Update src/content/docs/workers/static-assets/index.mdx Co-authored-by: Greg Brimble --- src/content/docs/workers/static-assets/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index 07e08bda40d3322..daec9f7de7094bf 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -85,7 +85,7 @@ export default { By default, if a requested URL matches a file in the static assets directory, that file will be served — without invoking Worker code. If no matching asset is found and a Worker script is present, the request will be processed by the Worker. The Worker can return a response or choose to defer again to static assets by using the [assets binding](/workers/static-assets/binding/) (e.g. `env.ASSETS.fetch(request)`). If no Worker script is present, a `404 Not Found` response is returned. -The default behavior when neither an asset nor a Worker is found can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration: +The default behavior when neither an asset nor a Worker script is found can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration file: - `not_found_handling = "single-page-application"`: Sets your application to return `index.html` for unmatched routes. Use this if you have a Single Page Application. - `not_found_handling = "404-page""`: Sets your application to return `404.html` for unmatched routes. From f5ebf9200b3b77bd45bba063475badee10d6aae7 Mon Sep 17 00:00:00 2001 From: lrapoport-cf Date: Thu, 8 May 2025 14:32:41 -0400 Subject: [PATCH 7/7] Updates --- src/content/docs/workers/static-assets/index.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index daec9f7de7094bf..3293be5d20c7716 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -85,10 +85,10 @@ export default { By default, if a requested URL matches a file in the static assets directory, that file will be served — without invoking Worker code. If no matching asset is found and a Worker script is present, the request will be processed by the Worker. The Worker can return a response or choose to defer again to static assets by using the [assets binding](/workers/static-assets/binding/) (e.g. `env.ASSETS.fetch(request)`). If no Worker script is present, a `404 Not Found` response is returned. -The default behavior when neither an asset nor a Worker script is found can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration file: +The default behavior for requests which don't match a static asset can be changed by setting the [`not_found_handling` option under `assets`](/workers/wrangler/configuration/#assets) in your Wrangler configuration file: -- `not_found_handling = "single-page-application"`: Sets your application to return `index.html` for unmatched routes. Use this if you have a Single Page Application. -- `not_found_handling = "404-page""`: Sets your application to return `404.html` for unmatched routes. +- [`not_found_handling = "single-page-application"`](/workers/static-assets/routing/single-page-application/): Sets your application to return a `200 OK` response with `index.html` for requests which don't match a static asset. Use this if you have a Single Page Application. +- [`not_found_handling = "404-page"`](/workers/static-assets/routing/static-site-generation/#custom-404-pages): Sets your application to return a `404 Not Found` response with the nearest `404.html` for requests which don't match a static asset.