1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 04:45:22 -04:00

fix base URL detection

This commit is contained in:
Jake Jarvis 2023-09-01 10:49:20 -04:00
parent 07155659c0
commit f69f3b225b
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

View File

@ -13,9 +13,13 @@ const nextConfig = {
productionBrowserSourceMaps: true,
transpilePackages: ["@novnc/novnc"],
env: {
BASE_URL: process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: `http://localhost:${process.env.PORT || 3000}`,
BASE_URL:
// start with production check on Vercel, then see if this is a deploy preview, then fallback to local dev server.
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
? `https://${config.siteDomain}`
: process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` // https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables
: `http://localhost:${process.env.PORT || 3000}`, // https://nextjs.org/docs/api-reference/cli#development
// freeze timestamp at build time for when server-side pages need a "last updated" date. calling Date.now() from
// pages using getServerSideProps will return the current(ish) time instead, which is usually not what we want.
RELEASE_DATE: new Date().toISOString(),