From f099a4ff969be68518146e8640bee6232ece1781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Thu, 21 Sep 2023 21:29:09 +0100 Subject: [PATCH] Switch to cloudflarepreviews.com (#4007) * Switch to cloudflarepreviews.com * Extract to env vars --- packages/playground-preview-worker/wrangler.json | 6 +++--- packages/workers-playground/.env | 2 ++ packages/workers-playground/.gitignore | 3 ++- .../src/QuickEditor/useDraftWorker.ts | 10 ++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 packages/workers-playground/.env diff --git a/packages/playground-preview-worker/wrangler.json b/packages/playground-preview-worker/wrangler.json index 40773fc085c7..b0845346e2e0 100644 --- a/packages/playground-preview-worker/wrangler.json +++ b/packages/playground-preview-worker/wrangler.json @@ -17,7 +17,7 @@ "define": { "ROOT": "'playground/devprod/cloudflare/dev'", - "PREVIEW": "':any/playground/devprod/cloudflare/dev'" + "PREVIEW": "':any/cloudflarepreviews/com'" }, "routes": [ @@ -26,8 +26,8 @@ "zone_name": "playground.devprod.cloudflare.dev" }, { - "pattern": "*.playground.devprod.cloudflare.dev/*", - "zone_name": "playground.devprod.cloudflare.dev" + "pattern": "*.cloudflarepreviews.com/*", + "zone_name": "cloudflarepreviews.com" } ], diff --git a/packages/workers-playground/.env b/packages/workers-playground/.env new file mode 100644 index 000000000000..b4977e6abfa2 --- /dev/null +++ b/packages/workers-playground/.env @@ -0,0 +1,2 @@ +VITE_PLAYGROUND_ROOT=playground.devprod.cloudflare.dev +VITE_PLAYGROUND_PREVIEW=cloudflarepreviews.com \ No newline at end of file diff --git a/packages/workers-playground/.gitignore b/packages/workers-playground/.gitignore index 54f07af58b4c..6a22c34982fe 100644 --- a/packages/workers-playground/.gitignore +++ b/packages/workers-playground/.gitignore @@ -21,4 +21,5 @@ dist-ssr *.ntvs* *.njsproj *.sln -*.sw? \ No newline at end of file +*.sw? +!.env \ No newline at end of file diff --git a/packages/workers-playground/src/QuickEditor/useDraftWorker.ts b/packages/workers-playground/src/QuickEditor/useDraftWorker.ts index d4968a8ba14e..c1a74ca1a512 100644 --- a/packages/workers-playground/src/QuickEditor/useDraftWorker.ts +++ b/packages/workers-playground/src/QuickEditor/useDraftWorker.ts @@ -118,10 +118,12 @@ async function updatePreviewHash(content: Worker): Promise { return { playgroundUrl: `/playground#${await compressWorker(worker)}`, - previewUrl: `https://${v4()}.playground.devprod.cloudflare.dev/.update-preview-token?token=${encodeURIComponent( - deploy.preview - )}`, - devtoolsUrl: `wss://playground.devprod.cloudflare.dev${deploy.inspector}`, + previewUrl: `https://${v4()}.${ + import.meta.env.VITE_PLAYGROUND_PREVIEW + }/.update-preview-token?token=${encodeURIComponent(deploy.preview)}`, + devtoolsUrl: `wss://${import.meta.env.VITE_PLAYGROUND_ROOT}${ + deploy.inspector + }`, }; }