Next.js Discord

Discord Forum

Deployment error

Answered
New Zealand posted this in #help-forum
Open in Discord
New ZealandOP
Hello, I have been trying to fix a deployment issue with vercel with no success the error i am getting is Image1, when it comes to local development the project does not have any issue. I am using contentful for cms and route.ts

import { client } from "@/lib/contentful_config"; import { NextResponse } from "next/server"; export const dynamic = "force-dynamic"; export const GET = async (request: Request) => { const entries = await client.getEntries({ content_type: "something" }); return NextResponse.json(entries.items); };

NB: locally everything is fine apart from when i deploy it to vercel.
Answered by New Zealand
I have discovered the solution it turns out that vercel can not handle deploying a huge project at once so i broke down my deployment into chunks of commits and it worked out for me thank you very much
View full answer

6 Replies

You're going to need to debug your fetch cause its not returning a json response(meaning its failing).
Also a ok check is a must imo especially when you are dealing with third party api:

const res = await fetch(..);
if(!res.ok) // do error handling
// else
const resJson = res.json()
@Clown Also a `ok` check is a must imo especially when you are dealing with third party api: js const res = await fetch(..); if(!res.ok) // do error handling // else const resJson = res.json()
New ZealandOP
Does this count?
export const get_data = async (endpoint: string) => { try { const baseUrl = process.env.NEXT_PUBLIC_BASE_URL; const response = await fetch(${baseUrl}/${endpoint}); const data = await response.json(); return data; } catch (error) { console.log(error); } };
Checkered Giant
I'm having a similar issue.
Kindly check it here
https://github.com/vercel/next.js/discussions/67278
New ZealandOP
I have discovered the solution it turns out that vercel can not handle deploying a huge project at once so i broke down my deployment into chunks of commits and it worked out for me thank you very much
Answer