From 36d349442e1aa07a3237a672eab012ccc3b4d8af Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Thu, 9 May 2024 22:31:31 +0200 Subject: [PATCH] set public URL to R2 --- .dev.vars | 1 - src/select-zls-version.ts | 6 ++++++ wrangler.toml | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.dev.vars b/.dev.vars index 5d6d599..27bbe4e 100644 --- a/.dev.vars +++ b/.dev.vars @@ -1,2 +1 @@ API_TOKEN=amogus -R2_PUBLIC_URL=R2_PLACERHOLDER_PUBLIC_URL \ No newline at end of file diff --git a/src/select-zls-version.ts b/src/select-zls-version.ts index 825af48..ffc50a4 100644 --- a/src/select-zls-version.ts +++ b/src/select-zls-version.ts @@ -76,6 +76,12 @@ export async function handleSelectZLSVersion( }); } + if (typeof env.R2_PUBLIC_URL !== "string" || !env.R2_PUBLIC_URL) { + return new Response(null, { + status: 500, // Internal Server Error + }); + } + const url = new URL(request.url); const zigVersionString = url.searchParams.get("zig_version"); diff --git a/wrangler.toml b/wrangler.toml index c1af31e..ca2805a 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -6,8 +6,8 @@ compatibility_flags = ["nodejs_compat"] # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables) # Note: Use secrets to store sensitive data. # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables -# [vars] -# MY_VARIABLE = "production_value" +[vars] +R2_PUBLIC_URL="https://builds.zigtools.org" # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database. # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases