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 connectToDb from "../src/server/db";
|
||||||
import { normalizeRow } from "../src/server/util";
|
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) {
|
async function handle(req, res) {
|
||||||
// Load index.html as our initial page content. If this fails, it probably
|
// 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
|
// 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(
|
const updatedAtTimestamp = Math.floor(
|
||||||
new Date(outfit.updatedAt).getTime() / 1000
|
new Date(outfit.updatedAt).getTime() / 1000
|
||||||
);
|
);
|
||||||
const outfitUrl = `https://impress-2020.openneo.net/outfits/${encodeURIComponent(
|
const outfitUrl = `${DTI_HOST}/outfits/${encodeURIComponent(outfit.id)}`;
|
||||||
outfit.id
|
const imageUrl = `${DTI_HOST}/api/outfitImage?size=600&id=${encodeURIComponent(
|
||||||
)}`;
|
|
||||||
const imageUrl = `https://impress-2020.openneo.net/api/outfitImage?size=600&id=${encodeURIComponent(
|
|
||||||
outfit.id
|
outfit.id
|
||||||
)}&updatedAt=${updatedAtTimestamp}`;
|
)}&updatedAt=${updatedAtTimestamp}`;
|
||||||
const metaTags = `
|
const metaTags = `
|
||||||
|
@ -112,12 +116,7 @@ async function loadIndexPageHtml() {
|
||||||
if (cachedIndexPageHtml == null) {
|
if (cachedIndexPageHtml == null) {
|
||||||
// Request the same built copy of index.html that we're already serving at
|
// Request the same built copy of index.html that we're already serving at
|
||||||
// our homepage.
|
// our homepage.
|
||||||
const homepageUrl = process.env.VERCEL_URL
|
const liveIndexPageHtml = await fetch(`${DTI_HOST}/`).then((res) =>
|
||||||
? `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) =>
|
|
||||||
res.text()
|
res.text()
|
||||||
);
|
);
|
||||||
cachedIndexPageHtml = liveIndexPageHtml;
|
cachedIndexPageHtml = liveIndexPageHtml;
|
||||||
|
|
Loading…
Reference in a new issue