My app works on v0 but getting errors when I try to deploy on vercel

When I try to deploy to vercel I get a server side error that I don’t know how to resolve. The apps works fine on v0 but throws an error on vercel. I am attaching the log below. Any ideas how to troubleshoot this? My app is using supabase as a backend database. What am I missing here? Is there any additional preparation to be done on the v0 side that is not automated?

08:32:57.863 Get questions error: TypeError: e.from is not a function
08:32:57.864 at p (/vercel/path1/.next/server/app/api/questions/route.js:1:1066)
08:32:57.864 at /vercel/path1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37016
08:32:57.864 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:140:36
08:32:57.864 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:57.865 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:57.865 at NoopTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
08:32:57.865 at ProxyTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
08:32:57.866 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:122:103
08:32:57.866 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:57.866 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:57.937 Generating static pages (11/23)
08:32:57.971 Export error: TypeError: e.from is not a function
08:32:57.971 at l (/vercel/path1/.next/server/app/api/responses/export/route.js:1:1064)
08:32:57.972 at /vercel/path1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37016
08:32:57.972 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:140:36
08:32:57.972 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:57.972 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:57.972 at NoopTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
08:32:57.973 at ProxyTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
08:32:57.973 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:122:103
08:32:57.973 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:57.973 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:57.989 Load responses error: n [Error]: Dynamic server usage: Route /api/responses/load couldn’t be rendered statically because it used cookies. See more info here: DynamicServerError - Dynamic Server Usage | Next.js
08:32:57.990 at l (/vercel/path1/.next/server/chunks/787.js:1:37140)
08:32:57.990 at f (/vercel/path1/.next/server/chunks/845.js:1:1676)
08:32:57.990 at p (/vercel/path1/.next/server/app/api/responses/load/route.js:1:2162)
08:32:57.991 at /vercel/path1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37016
08:32:57.992 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:140:36
08:32:57.992 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:57.992 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:57.992 at NoopTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
08:32:57.993 at ProxyTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
08:32:57.999 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:122:103 {
08:32:57.999 description: “Route /api/responses/load couldn’t be rendered statically because it used cookies. See more info here: DynamicServerError - Dynamic Server Usage | Next.js”,
08:32:57.999 digest: ‘DYNAMIC_SERVER_USAGE’
08:32:57.999 }
08:32:58.026 Summary error: TypeError: e.from is not a function
08:32:58.026 at l (/vercel/path1/.next/server/app/api/responses/summary/route.js:1:1066)
08:32:58.027 at /vercel/path1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37016
08:32:58.027 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:140:36
08:32:58.027 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:58.027 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:58.027 at NoopTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
08:32:58.030 at ProxyTracer.startActiveSpan (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
08:32:58.031 at /vercel/path1/node_modules/next/dist/server/lib/trace/tracer.js:122:103
08:32:58.031 at NoopContextManager.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
08:32:58.031 at ContextAPI.with (/vercel/path1/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
08:32:58.268 Generating static pages (17/23)
08:32:58.479 ✓ Generating static pages (23/23)
08:32:58.664 Finalizing page optimization …
08:32:58.664 Collecting build traces …

Since the logs you shared show multiple instances of TypeError: e.from is not a function on api routes and a dynamic server usage error, there could be an issue with imports in the server side code.

Try checking the API route files (e.g. /app/api/questions/route.js) to be sure imports are correct. For example,

import { createClient } from '@supabase/supabase-js'

// or

import { cookies } from 'next/headers'

export async function GET() {
  const cookieStore = await cookies() // Make sure to await this
  // rest of your code
}

Thank you Amy my app/api/questions/route..ts files does not use any cookies. Here is the whole file. Do you have any suggestions what to add here?

import { type NextRequest, NextResponse } from “next/server”
import { createClient } from “@/lib/supabase/server”

export async function GET(request: NextRequest) {
try {
const supabase = createClient()

const { data: questions, error } = await supabase
  .from("questions")
  .select("*")
  .order("order_index", { ascending: true })

if (error) {
  return NextResponse.json(
    {
      error: "Database error: " + error.message,
    },
    { status: 500 },
  )
}

return NextResponse.json({ questions: questions || [] })

} catch (error) {
console.error(“Get questions error:”, error)
return NextResponse.json(
{
error: “Internal server error”,
},
{ status: 500 },
)
}
}