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.
This commit is contained in:
Emi Matchu 2021-05-14 20:28:33 -07:00
parent 5e657e7547
commit d31809cc62

View file

@ -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