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