From d31809cc626b2972fb03fdbb4b5c678141f992f9 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 14 May 2021 20:28:33 -0700 Subject: [PATCH] Use VERCEL_URL in /api/outfitImage Ah right, this is how we get the deployed API code to know its own hostname! This way, when we do a preview deploy, /api/outfitImage will use the preview version of the GraphQL endpoint, too. --- api/outfitImage.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/outfitImage.js b/api/outfitImage.js index 78f9741..3ebfc55 100644 --- a/api/outfitImage.js +++ b/api/outfitImage.js @@ -118,10 +118,11 @@ async function handle(req, res) { return res.send(image); } -const GRAPHQL_ENDPOINT = - process.env.NODE_ENV === "development" - ? "http://localhost:3000/api/graphql" - : "https://impress-2020.openneo.net/api/graphql"; +const GRAPHQL_ENDPOINT = process.env.VERCEL_URL + ? `https://${process.env.VERCEL_URL}/api/graphql` + : process.env.NODE_ENV === "development" + ? "http://localhost:3000/api/graphql" + : "https://impress-2020.openneo.net/api/graphql"; // NOTE: Unlike in-app views, we only load PNGs here. We expect this to // generally perform better, and be pretty reliable now that TNT is