Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/content/docs/workers/configuration/previews.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 4 additions & 1 deletion src/content/docs/workers/wrangler/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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` <Type text="boolean" /> <MetaInfo text="optional" />

- Enables use of `*<worker-name>.workers.dev` previews to test versions of your Worker. Defaults to `true`.

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

- 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).
Expand Down Expand Up @@ -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/).
Expand Down
Loading