Skip to content

Commit ec7217a

Browse files
committed
Document preview URL disablement
1 parent 3ba931c commit ec7217a

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/content/docs/workers/configuration/previews.mdx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,42 @@ You must press enter after you input your Application domain for it to save. You
6060

6161
6. Go to the next page.
6262
7. Add a name for your access policy (for example, "Allow employees access to preview URLs for my-worker").
63-
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.
63+
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.
6464
9. Enter the emails you want to authorize. View [access policies](/cloudflare-one/policies/access/#selectors) to learn about configuring alternate rules.
6565
10. Go to the next page.
6666
11. Add application.
6767

6868
## Making Preview URLs inaccessible
6969

70-
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).
70+
Preview URLs run on your [`workers.dev` subdomain](/workers/configuration/routing/workers-dev/). You can disable preview URLs to make them inaccessible.
71+
72+
### Disable on the Cloudflare dashboard
73+
74+
1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account.
75+
2. Go to **Workers** > your Worker.
76+
3. Go to **Settings**.
77+
4. In the "Domains & Routes" section click "Disable" on "Preview URLs".
78+
5. Confirm you want to disable.
79+
80+
### Disable in Wrangler
81+
82+
::note
83+
Wrangler vXX or higher is required to use this feature.
84+
::
85+
86+
In your `wrangler.toml` you can add `preview_urls = false` to disable preview URLs from being accessible.
87+
88+
```toml
89+
name = "my-worker"
90+
compatibility_date = "2024-01-01"
91+
preview_urls = false
92+
```
93+
94+
This will be applied when doing `wrangler deploy` or `wrangler triggers deploy` if using [Gradual Deployments](/workers/configuration/versions-and-deployments/gradual-deployments).
7195

7296
## Limitations
7397

7498
- Preview URLs are not generated for Workers that implement a [Durable Object](/durable-objects/).
7599
- 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.
76100
- You cannot currently configure Preview URLs to run on a subdomain other than [`workers.dev`](/workers/configuration/routing/workers-dev/).
101+
- You cannot use `wrangler tail`, [Workers Logs](/workers/observability/logs/workers-logs) or other similar tools to view logs for preview URLs.

src/content/docs/workers/configuration/routing/workers-dev.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ To disable the `workers.dev` route for a Worker, include the following in your W
2727
workers_dev = false
2828
```
2929

30-
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.
30+
When you redeploy your Worker with this change, the `workers.dev` route will be disabled.
31+
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).
3132

3233
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.
3334

src/content/docs/workers/wrangler/configuration.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ At a minimum, the `name`, `main` and `compatibility_date` keys are required to d
108108

109109
- 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`.
110110

111+
- `preview_urls` <Type text="boolean" /> <MetaInfo text="optional" />
112+
113+
- Enables use of `*<worker-name>.workers.dev` previews to test versions of your Worker. Defaults to `true`.
114+
111115
- `route` <Type text="Route" /> <MetaInfo text="optional" />
112116

113117
- 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
345349
head_sampling_rate = 0.1 # 10% of requests are logged
346350
```
347351

348-
349352
## Custom builds
350353

351354
You can configure a custom build step that will be run before your Worker is deployed. Refer to [Custom builds](/workers/wrangler/custom-builds/).

0 commit comments

Comments
 (0)