Use VERCEL_URL for waka loader if given

Oh right, our preview deploy was loading the prod allWakaValues data! Now it uses the VERCEL_URL env variable to request from the current deployment instead.
This commit is contained in:
Emi Matchu 2021-04-07 22:02:10 -07:00
parent a32bc34171
commit 089654e092

View file

@ -608,10 +608,11 @@ const buildItemWakaValueLoader = () =>
// API would, and avoid putting pressure on our Google Sheets API quotas. // API would, and avoid putting pressure on our Google Sheets API quotas.
// (Some kind of internal memcache or process-level cache would be a more // (Some kind of internal memcache or process-level cache would be a more
// idiomatic solution in a monolith server environment!) // idiomatic solution in a monolith server environment!)
const url = const url = process.env.VERCEL_URL
process.env.NODE_ENV === "production" ? `https://${process.env.VERCEL_URL}/api/allWakaValues`
? "https://impress-2020.openneo.net/api/allWakaValues" : process.env.NODE_ENV === "production"
: "http://localhost:3000/api/allWakaValues"; ? "https://impress-2020.openneo.net/api/allWakaValues"
: "http://localhost:3000/api/allWakaValues";
const res = await fetch(url); const res = await fetch(url);
if (!res.ok) { if (!res.ok) {
throw new Error( throw new Error(