Skip to content

Commit 605b73d

Browse files
tanushree-sharmahyperlint-ai[bot]GregBrimbledcpena
authored andcommitted
[Workers] Version previews behind Access (#17239)
* previews + nextjs fix * Apply suggestions from code review Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Greg Brimble <[email protected]> * Apply suggestions from code review Co-authored-by: Greg Brimble <[email protected]> * Apply suggestions from code review Co-authored-by: Denise Peña <[email protected]> * Apply suggestions from code review --------- Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> Co-authored-by: Greg Brimble <[email protected]> Co-authored-by: Denise Peña <[email protected]>
1 parent 02d7b85 commit 605b73d

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Render } from "~/components";
1212

1313
Preview URLs allow you to preview new versions of your Worker without deploying it to production.
1414

15-
Every time you create a new [version](/workers/configuration/versions-and-deployments/#versions) of your Worker a unique preview URL is generated. 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.
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.
1616

1717
Preview URLs can be:
1818

@@ -24,6 +24,8 @@ When testing zone level performance or security featues for a version, we recomm
2424

2525
:::note
2626
Preview URLs are only available for Worker versions uploaded after 2024-09-25.
27+
28+
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/).
2729
:::
2830

2931
## View preview URLs using wrangler
@@ -35,6 +37,34 @@ The [`wrangler versions upload`](/workers/wrangler/commands/#upload) command upl
3537
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers) and select your project.
3638
2. Head to the "Deployments" tab find the version you would like to view.
3739

40+
## Manage access to Preview URLs
41+
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).
43+
44+
To limit your preview URLs to authorized emails only:
45+
46+
1. Log in to the [Cloudflare Access dashboard](https://one.dash.cloudflare.com/?to=/:account/access/apps).
47+
2. Select your account.
48+
3. Add an application.
49+
4. Select **Self Hosted**.
50+
5. Name your application (for example, "my-worker") and add your `workers.dev` subdomain as the **Application domain**.
51+
52+
For example, if you want to secure preview URLs for a Worker running on `my-worker.my-subdomain.workers.dev`.
53+
54+
- Subdomain: `*-my-worker`
55+
- Domain: `my-subdomain.workers.dev`
56+
57+
:::note
58+
You must press enter after you input your Application domain for it to save. You will see a "Zone is not associated with the current account" warning that you may ignore.
59+
:::
60+
61+
6. Go to the next page.
62+
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.
64+
9. Enter the emails you want to authorize. View [access policies](/cloudflare-one/policies/access/#selectors) to learn about configuring alternate rules.
65+
10. Go to the next page.
66+
11. Add application.
67+
3868
## Making Preview URLs inaccessible
3969

4070
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).
@@ -43,4 +73,3 @@ Preview URLs run on your [`workers.dev` subdomain](/workers/configuration/routin
4373

4474
- Preview URLs are not generated for Workers that implement a [Durable Object](/durable-objects/).
4575
- 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.
46-
- You cannot currently secure `workers.dev` URLs behind [Cloudflare Access](/cloudflare-one/policies/access/). This is a temporary limitation, we are working to remove it.

src/content/docs/workers/frameworks/framework-guides/nextjs.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ To create a new Next.js app, pre-configured to run on Cloudflare using [`@openne
3838

3939
Check your version by running `wrangler version`. To update Wrangler, refer to [Install/Update Wrangler](/workers/wrangler/install-and-update/).
4040

41+
:::note
42+
43+
Minimum required Wrangler version: 3.78.10. Check your version by running `wrangler --version`. To update Wrangler, refer to [Install/Update Wrangler](/workers/wrangler/install-and-update/).
44+
4145
:::
4246

4347
### 1. Install @opennextjs/cloudflare

0 commit comments

Comments
 (0)