Vercel deploy fail, I know the reason but not how to fix
Answered
Waterman posted this in #help-forum
WatermanOP
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?
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?
10 Replies
WatermanOP
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?
WatermanOP
WatermanOP
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
@Waterman ok thanks alot, but I don't quite understand everything, how would I do things differently if this is my code?
javascript
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...
how does your /api/basproducts look like?
Answer
WatermanOP
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:)