From ec7217ac2f8314c269ae3448a429d756813cbbac Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Mon, 25 Nov 2024 14:34:34 +0000 Subject: [PATCH] Document preview URL disablement --- .../docs/workers/configuration/previews.mdx | 29 +++++++++++++++++-- .../configuration/routing/workers-dev.mdx | 3 +- .../docs/workers/wrangler/configuration.mdx | 5 +++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/configuration/previews.mdx b/src/content/docs/workers/configuration/previews.mdx index e5e6ac702685139..92fe14802fa27fc 100644 --- a/src/content/docs/workers/configuration/previews.mdx +++ b/src/content/docs/workers/configuration/previews.mdx @@ -60,17 +60,42 @@ You must press enter after you input your Application domain for it to save. You 6. Go to the next page. 7. Add a name for your access policy (for example, "Allow employees access to preview URLs for my-worker"). -8. In the **Configure rules** section create a new rule with the **Emails** selector, or any other attributes which you wish to gate access to previews with. +8. In the **Configure rules** section create a new rule with the **Emails** selector, or any other attributes which you wish to gate access to previews with. 9. Enter the emails you want to authorize. View [access policies](/cloudflare-one/policies/access/#selectors) to learn about configuring alternate rules. 10. Go to the next page. 11. Add application. ## Making Preview URLs inaccessible -Preview URLs run on your [`workers.dev` subdomain](/workers/configuration/routing/workers-dev/). To make preview URLs inaccessible, you must disable your Workers `workers.dev` subdomain. Learn how to [disable your Workers `workers.dev` subdomain](/workers/configuration/routing/workers-dev/#disabling-workersdev). +Preview URLs run on your [`workers.dev` subdomain](/workers/configuration/routing/workers-dev/). You can disable preview URLs to make them inaccessible. + +### Disable on the Cloudflare dashboard + +1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account. +2. Go to **Workers** > your Worker. +3. Go to **Settings**. +4. In the "Domains & Routes" section click "Disable" on "Preview URLs". +5. Confirm you want to disable. + +### Disable in Wrangler + +::note +Wrangler vXX or higher is required to use this feature. +:: + +In your `wrangler.toml` you can add `preview_urls = false` to disable preview URLs from being accessible. + +```toml +name = "my-worker" +compatibility_date = "2024-01-01" +preview_urls = false +``` + +This will be applied when doing `wrangler deploy` or `wrangler triggers deploy` if using [Gradual Deployments](/workers/configuration/versions-and-deployments/gradual-deployments). ## Limitations - Preview URLs are not generated for Workers that implement a [Durable Object](/durable-objects/). - Preview URLs are not currently generated for [Workers for Platforms](/cloudflare-for-platforms/workers-for-platforms/) [user Workers](/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#user-workers). This is a temporary limitation, we are working to remove it. - You cannot currently configure Preview URLs to run on a subdomain other than [`workers.dev`](/workers/configuration/routing/workers-dev/). +- You cannot use `wrangler tail`, [Workers Logs](/workers/observability/logs/workers-logs) or other similar tools to view logs for preview URLs. diff --git a/src/content/docs/workers/configuration/routing/workers-dev.mdx b/src/content/docs/workers/configuration/routing/workers-dev.mdx index 7368a06bcf62a49..3f19a8dbd13cfbe 100644 --- a/src/content/docs/workers/configuration/routing/workers-dev.mdx +++ b/src/content/docs/workers/configuration/routing/workers-dev.mdx @@ -27,7 +27,8 @@ To disable the `workers.dev` route for a Worker, include the following in your W workers_dev = false ``` -When you redeploy your Worker with this change, the `workers.dev` route will be disabled. Disabling your `workers.dev` subdomain will also make [preview URLs](/workers/configuration/previews) inaccessible. +When you redeploy your Worker with this change, the `workers.dev` route will be disabled. +Disabling your `workers.dev` subdomain will not make [preview URLs](/workers/configuration/previews) inaccessible, to do that [see here](/workers/configuration/previews/#making-preview-urls-inaccessible). If you do not specify `workers_dev = false` but add a [`routes` component](/workers/wrangler/configuration/#routes) to your `wrangler.toml`, the value of `workers_dev` will be inferred as `false` on the next deploy. diff --git a/src/content/docs/workers/wrangler/configuration.mdx b/src/content/docs/workers/wrangler/configuration.mdx index 9e5a14721a763de..017fdd850d2cce2 100644 --- a/src/content/docs/workers/wrangler/configuration.mdx +++ b/src/content/docs/workers/wrangler/configuration.mdx @@ -108,6 +108,10 @@ At a minimum, the `name`, `main` and `compatibility_date` keys are required to d - Enables use of `*.workers.dev` subdomain to test and deploy your Worker. If you have a Worker that is only for `scheduled` events, you can set this to `false`. Defaults to `true`. +- `preview_urls` + + - Enables use of `*.workers.dev` previews to test versions of your Worker. Defaults to `true`. + - `route` - A route that your Worker should be deployed to. Only one of `routes` or `route` is required. Refer to [types of routes](#types-of-routes). @@ -345,7 +349,6 @@ enabled = true head_sampling_rate = 0.1 # 10% of requests are logged ``` - ## Custom builds You can configure a custom build step that will be run before your Worker is deployed. Refer to [Custom builds](/workers/wrangler/custom-builds/).