Next.js Discord

Discord Forum

Domain URL during Build

Unanswered
Segugio Maremmano posted this in #help-forum
Open in Discord
Segugio MaremmanoOP
I have a use-case like this -
export const metadata: Metadata = {
  title: "Portfolio website",
  description: "A new portfolio website, using Next.js",
  openGraph: {
    title: "Portfolio website",
    description: "A new portfolio website, using Next.js",
    images: [
      {
        url: `/images/og-image.png`,
      },
    ],
  },
};


However this yields a warning during the build that the OG Image url is not valid (http://localhost:PORT).
I am using Coolify to trigger a preview when a PR is created. How do we pass the latest preview URL to create the absolute URL for the images?

I am guessing something with an .env/metadataBase: new URL('...') but not sure how'd that work. Any ideas?
Thanx.

0 Replies