Use current host for outfit share tags
This will help test preview pages and such!
This commit is contained in:
parent
2bc2fc5bfe
commit
a0121f09ea
1 changed files with 9 additions and 10 deletions
|
@ -27,6 +27,12 @@ import fetch from "node-fetch";
|
|||
import connectToDb from "../src/server/db";
|
||||
import { normalizeRow } from "../src/server/util";
|
||||
|
||||
const DTI_HOST = process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}`
|
||||
: process.env.NODE_ENV === "development"
|
||||
? "http://localhost:3000"
|
||||
: "https://impress-2020.openneo.net";
|
||||
|
||||
async function handle(req, res) {
|
||||
// Load index.html as our initial page content. If this fails, it probably
|
||||
// means something is misconfigured in a big way; we don't have a great way
|
||||
|
@ -76,10 +82,8 @@ async function handle(req, res) {
|
|||
const updatedAtTimestamp = Math.floor(
|
||||
new Date(outfit.updatedAt).getTime() / 1000
|
||||
);
|
||||
const outfitUrl = `https://impress-2020.openneo.net/outfits/${encodeURIComponent(
|
||||
outfit.id
|
||||
)}`;
|
||||
const imageUrl = `https://impress-2020.openneo.net/api/outfitImage?size=600&id=${encodeURIComponent(
|
||||
const outfitUrl = `${DTI_HOST}/outfits/${encodeURIComponent(outfit.id)}`;
|
||||
const imageUrl = `${DTI_HOST}/api/outfitImage?size=600&id=${encodeURIComponent(
|
||||
outfit.id
|
||||
)}&updatedAt=${updatedAtTimestamp}`;
|
||||
const metaTags = `
|
||||
|
@ -112,12 +116,7 @@ async function loadIndexPageHtml() {
|
|||
if (cachedIndexPageHtml == null) {
|
||||
// Request the same built copy of index.html that we're already serving at
|
||||
// our homepage.
|
||||
const homepageUrl = process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}/`
|
||||
: process.env.NODE_ENV === "development"
|
||||
? "http://localhost:3000/"
|
||||
: "https://impress-2020.openneo.net/";
|
||||
const liveIndexPageHtml = await fetch(homepageUrl).then((res) =>
|
||||
const liveIndexPageHtml = await fetch(`${DTI_HOST}/`).then((res) =>
|
||||
res.text()
|
||||
);
|
||||
cachedIndexPageHtml = liveIndexPageHtml;
|
||||
|
|
Loading…
Reference in a new issue