Skip to content

Commit b15a5a7

Browse files
taylorleeWillTaylorDevGregBrimble
authored
[Workers] Document preview_urls config (#19068)
* [Workers] Document preview_urls config * fix routes config sections for new UI (custom domains already fixed) * add dash section for disabling workers.dev * add sections for disabling preview-urls * add `preview_urls` to wrangler config section * Apply suggestions from code review Co-authored-by: WillTaylorDev <[email protected]> Co-authored-by: Greg Brimble <[email protected]> * Apply suggestions from code review --------- Co-authored-by: WillTaylorDev <[email protected]> Co-authored-by: Greg Brimble <[email protected]>
1 parent 84af769 commit b15a5a7

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,42 @@ You must press enter after you input your Application domain for it to save. You
6565
10. Go to the next page.
6666
11. Add application.
6767

68-
## Making Preview URLs inaccessible
68+
## Disabling Preview URLs
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+
### Disabling Preview URLs in the dashboard
71+
72+
To disable Preview URLs for a Worker:
73+
74+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
75+
2. Go to **Workers & Pages** and in **Overview**, select your Worker.
76+
3. Go to **Settings** > **Domains & Routes**.
77+
4. On "Preview URLs" click "Disable".
78+
5. Confirm you want to disable.
79+
80+
### Disabling Preview URLs in `wrangler.toml`
81+
82+
:::note
83+
Wrangler 3.91.0 or higher is required to use this feature.
84+
:::
85+
86+
To disable Preview URLs for a Worker, include the following in your Worker's `wrangler.toml` file:
87+
88+
import { WranglerConfig } from "~/components";
89+
90+
<WranglerConfig>
91+
92+
```toml
93+
preview_urls = false
94+
```
95+
96+
</WranglerConfig>
97+
98+
When you redeploy your Worker with this change, Preview URLs will be disabled.
99+
100+
:::caution
101+
102+
If you disable Preview URLs in the Cloudflare dashboard but do not update your Worker's `wrangler.toml` file with `preview_urls = false`, then Preview URLs will be re-enabled the next time you deploy your Worker with Wrangler.
103+
:::
71104

72105
## Limitations
73106

src/content/docs/workers/configuration/routing/routes.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ To set up a route in the dashboard:
4343

4444
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
4545
2. Go to **Workers & Pages** and in **Overview**, select your Worker.
46-
3. Go to **Settings** > **Triggers** > **Routes** > **Add route**.
47-
4. Enter the route and select the zone it applies to.
46+
3. Go to **Settings** > **Domains & Routes** > **Add** > **Route**.
47+
4. Select the zone and enter the route pattern.
4848
5. Select **Add route**.
4949

5050
### Set up a route in `wrangler.toml`

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ All Workers are assigned a `workers.dev` route when they are created or renamed
1919

2020
## Disabling `workers.dev`
2121

22-
Review your `workers.dev` route in your Worker > **Settings** > **Domains & Routes**.
22+
### Disabling `workers.dev` in the dashboard
23+
24+
To disable the `workers.dev` route for a Worker:
25+
26+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
27+
2. Go to **Workers & Pages** and in **Overview**, select your Worker.
28+
3. Go to **Settings** > **Domains & Routes**.
29+
4. On `workers.dev` click "Disable".
30+
5. Confirm you want to disable.
31+
32+
### Disabling `workers.dev` in `wrangler.toml`
2333

2434
To disable the `workers.dev` route for a Worker, include the following in your Worker's `wrangler.toml` file:
2535

@@ -33,13 +43,13 @@ workers_dev = false
3343

3444
</WranglerConfig>
3545

36-
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.
46+
When you redeploy your Worker with this change, the `workers.dev` route will be disabled. Disabling your `workers.dev` route does not disable Preview URLs. Learn how to [disable Preview URLs](/workers/configuration/previews/#disabling-preview-urls).
3747

3848
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.
3949

4050
:::caution
4151

42-
If you disable your `workers.dev` route in the Cloudflare dashboard but do not update your Worker's `wrangler.toml` file with `workers_dev = false`, the `workers.dev` route will re-enable the next time you publish your Worker.
52+
If you disable your `workers.dev` route in the Cloudflare dashboard but do not update your Worker's `wrangler.toml` file with `workers_dev = false`, the `workers.dev` route will be re-enabled the next time you deploy your Worker with Wrangler.
4353
:::
4454

4555
## Limitations

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ At a minimum, the `name`, `main` and `compatibility_date` keys are required to d
113113

114114
- `workers_dev` <Type text="boolean" /> <MetaInfo text="optional" />
115115

116-
- 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`.
116+
- Enables use of `*.workers.dev` subdomain to deploy your Worker. If you have a Worker that is only for `scheduled` events, you can set this to `false`. Defaults to `true`. Refer to [types of routes](#types-of-routes).
117+
118+
- `preview_urls` <Type text="boolean" /> <MetaInfo text="optional" />
119+
120+
- Enables use of Preview URLs to test your Worker. Defaults to `true`. Refer to [Preview URLs](/workers/configuration/previews).
117121

118122
- `route` <Type text="Route" /> <MetaInfo text="optional" />
119123

0 commit comments

Comments
 (0)