Next.js Discord

Discord Forum

Vercel deploy fail, I know the reason but not how to fix

Answered
Waterman posted this in #help-forum
Open in Discord
So the reason for my deployment fail is because I use server components and in the code I fetch data from "${process.env.HOST}/api........" I have setup the environment variable as host but the deployment seems to be failiing because of that the domain doesn't exist before I deploy it

So basically, how can I deploy this successfully if it needs to be assigned to a domain that I don't have acces to yet?
Answered by joulev
how does your /api/basproducts look like?
View full answer

10 Replies

because when fetching data in server component I can't only use /api/... I need to do the full url it seems like, but it doesn't work
should I deploy a non fetching app to trigger the creation of the domain?
ok thanks alot, but I don't quite understand everything, how would I do things differently if this is my code?

async function getProducts() {
  const res = await fetch(`${process.env.HOST}/api/basproducts`);
  return res.json();
}

export default async function BasProdukterPresentation() {
  const products = await getProducts();

more code...
this is your example:
import { prisma } from "~/lib/prisma";

export default async function Page() {
  const user = await prisma.user.findUnique({ where: { id: 123456 } });
  return <div>{user?.name}</div>;
}
but what would the prisma be in my case if I have a mongoose connection to my mongo db database?
because at the moment I fetch data through a get request to a route that is giving me the details
Answer
I thank i just solved it:) instead of using the prisma part you had i just used my model and made mongooseconnection before fetching, thanks alot:)