Next.js Discord

Discord Forum

simple Q: how do you get the domain in preview/prodcution environment

Unanswered
Ghost ant posted this in #help-forum
Open in Discord
Ghost antOP
// react hook
const domain = "http://localhost:3000";
  const url = new URL(`${domain}/api/search`);
  const params = new URLSearchParams();
  params.append("name", input);

2 Replies

Shy Albatross
Is this a Vercel question, or generic?
in Vercel the production domain is not the same as its deployment URL, so what I do is just set the domain manually in env vars for production, then read that, because VERCEL_URL isn't correct