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,8 +118,9 @@ async function handle(req, res) {
return res.send(image); return res.send(image);
} }
const GRAPHQL_ENDPOINT = const GRAPHQL_ENDPOINT = process.env.VERCEL_URL
process.env.NODE_ENV === "development" ? `https://${process.env.VERCEL_URL}/api/graphql`
: process.env.NODE_ENV === "development"
? "http://localhost:3000/api/graphql" ? "http://localhost:3000/api/graphql"
: "https://impress-2020.openneo.net/api/graphql"; : "https://impress-2020.openneo.net/api/graphql";