Skip to content

Commit 165e041

Browse files
committed
Add documentation for preview aliases during version upload
1 parent 240d5f2 commit 165e041

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

src/content/docs/workers/configuration/multipart-upload-metadata.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ These attributes are **not available** for immediately deployed uploads.
109109
- Annotations object specific to the Worker version.
110110
- `workers/message` specifies a custom message for the version.
111111
- `workers/tag` specifies a custom identifier for the version.
112+
- `workers/alias` specifies a custom alias for this version.
112113

113114
## Bindings
114115

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

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ description: Preview URLs allow you to preview new versions of your project with
1010

1111
import { Render, WranglerConfig } from "~/components";
1212

13+
# Overview
14+
1315
Preview URLs allow you to preview new versions of your Worker without deploying it to production.
1416

15-
Every time you create a new [version](/workers/configuration/versions-and-deployments/#versions) of your Worker a unique preview URL is generated. Preview URLs take the format: `<VERSION_PREFIX>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev`. New [versions](/workers/configuration/versions-and-deployments/#versions) of a Worker are created on [`wrangler deploy`](/workers/wrangler/commands/#deploy), [`wrangler versions upload`](/workers/wrangler/commands/#upload) or when you make edits on the Cloudflare dashboard. By default, preview URLs are enabled and available publicly.
17+
There are two types of preview URLs:
18+
- **Version-Prefixed Preview URLs**: A unique URL generated automatically for each new version of your Worker.
19+
- **Alias Preview URLs**: A static, human-readable alias that you can manually assign to a Worker version.
20+
21+
Both preview URL types follow the format: `<VERSION_PREFIX OR ALIAS>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev`.
1622

1723
Preview URLs can be:
1824

@@ -24,22 +30,66 @@ When testing zone level performance or security features for a version, we recom
2430

2531
:::note
2632
Preview URLs are only available for Worker versions uploaded after 2024-09-25.
33+
:::
34+
35+
## Types of Preview URLs
36+
37+
### Version-Prefixed Preview URLs
38+
39+
Every time you create a new [version](/workers/configuration/versions-and-deployments/#versions) of your Worker, a unique static version preview URL is generated automatically. These URLs use a version prefix and follow the format `<VERSION_PREFIX>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev`.
2740

41+
New versions of a Worker are created when you run:
42+
43+
- [`wrangler deploy`](/workers/wrangler/commands/#deploy)
44+
- [`wrangler versions upload`](/workers/wrangler/commands/#upload)
45+
- Or when you make edits via the Cloudflare dashboard
46+
47+
These URLs are public by default and available immediately after version creation.
48+
49+
:::note
2850
Minimum required Wrangler version: 3.74.0. Check your version by running `wrangler --version`. To update Wrangler, refer to [Install/Update Wrangler](/workers/wrangler/install-and-update/).
2951
:::
3052

31-
## View preview URLs using wrangler
53+
#### View version-prefixed preview URLs using Wrangler
3254

3355
The [`wrangler versions upload`](/workers/wrangler/commands/#upload) command uploads a new [version](/workers/configuration/versions-and-deployments/#versions) of your Worker and returns a preview URL for each version uploaded.
3456

35-
## View preview URLs on the Workers dashboard
57+
#### View version-prefixed preview URLs on the Workers dashboard
3658

3759
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers) and select your project.
3860
2. Go to the **Deployments** tab, and find the version you would like to view.
3961

62+
### Aliased preview URLs
63+
64+
Aliased preview URLs let you assign a persistent, readable alias to a specific Worker version. These are useful for linking to stable previews across environments. These types of preview URLs follow the same pattern as other preview URLs:
65+
`<ALIAS>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev`
66+
67+
:::note
68+
Minimum required Wrangler version: `4.21.0`. Check your version by running `wrangler --version`. To update Wrangler, refer to [Install/Update Wrangler](/workers/wrangler/install-and-update/).
69+
:::
70+
71+
#### Create an Alias
72+
73+
Aliases may be created during `versions upload`, by providing the `--preview-alias` flag with a valid alias name:
74+
75+
```bash
76+
wrangler versions upload --preview-alias staging
77+
```
78+
79+
The resulting alias would be associated with this version, and immediately available at:
80+
`staging-<WORKER_NAME>.<SUBDOMAIN>.workers.dev`
81+
82+
#### Rules and limitations
83+
84+
- Aliases may only be created during version upload.
85+
- Aliases must use only lowercase letters, numbers, and dashes.
86+
- Aliases must begin with a lowercase letter.
87+
- The alias and Worker name combined (with a dash) must not exceed 63 characters due to DNS label limits.
88+
- Only the 20 most recently used aliases are retained. When a new alias is created beyond this limit, the least recently used alias is deleted.
89+
4090
## Manage access to Preview URLs
4191

42-
By default, preview URLs are enabled and available publicly. You can use [Cloudflare Access](/cloudflare-one/policies/access/) to require visitors to authenticate before accessing preview URLs. You can limit access to yourself, your teammates, your organization, or anyone else you specify in your [access policy](/cloudflare-one/policies/access).
92+
By default, all preview URLs are enabled and available publicly. You can use [Cloudflare Access](/cloudflare-one/policies/access/) to require visitors to authenticate before accessing preview URLs. You can limit access to yourself, your teammates, your organization, or anyone else you specify in your [access policy](/cloudflare-one/policies/access).
4393

4494
To limit your preview URLs to authorized emails only:
4595

@@ -67,6 +117,8 @@ You must press enter after you input your Application domain for it to save. You
67117

68118
## Disabling Preview URLs
69119

120+
Disabling Preview URLs will disable routing to both version-prefixed and aliased URLs.
121+
70122
### Disabling Preview URLs in the dashboard
71123

72124
To disable Preview URLs for a Worker:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,8 @@ wrangler versions upload [OPTIONS]
14641464
- Add a version tag. Accepts empty string.
14651465
- `--message` <Type text="string" /> <MetaInfo text="optional" />
14661466
- Add a version message. Accepts empty string.
1467+
- `--preview-alias` <Type text="string" /> <MetaInfo text="optional" />
1468+
- Creates an alias to this version.
14671469
- `--name` <Type text="string" /> <MetaInfo text="optional" />
14681470
- Perform on a specific Worker rather than inheriting from the [Wrangler configuration file](/workers/wrangler/configuration/).
14691471
- `--env` <Type text="string" /> <MetaInfo text="optional" />

0 commit comments

Comments
 (0)