Next.js Discord

Discord Forum

Error building at vercel

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
I am struggling with an issue in the deployment at vercel, locally npx next build is working fine but on vercel I am getting this error
[18:10:11.381] ReferenceError: window is not defined
[18:10:11.381] at Object.is_supported (/vercel/path0/.next/server/chunks/7097.js:1:26948)
[18:10:11.381] at e.value (/vercel/path0/.next/server/chunks/7097.js:1:107997)
[18:10:11.382] at e.value (/vercel/path0/.next/server/chunks/7097.js:1:90244)
[18:10:11.382] at di (/vercel/path0/.next/server/chunks/7097.js:1:87997)
[18:10:11.382] at tH.init (/vercel/path0/.next/server/chunks/7097.js:1:112601)
[18:10:11.382] at 68831 (/vercel/path0/.next/server/app/api/trpc/[trpc]/route.js:1:1832)
[18:10:11.382] at webpack_require (/vercel/path0/.next/server/webpack-runtime.js:1:146)
[18:10:11.383] at webpack_exec (/vercel/path0/.next/server/app/api/trpc/[trpc]/route.js:1:7909)
[18:10:11.383] at /vercel/path0/.next/server/app/api/trpc/[trpc]/route.js:1:7996
[18:10:11.389] at webpack_require.X (/vercel/path0/.next/server/webpack-runtime.js:1:1638)
[18:10:11.392]
[18:10:11.392] > Build error occurred
[18:10:11.392] Error: Failed to collect page data for /api/trpc/[trpc]
[18:10:11.392] at /vercel/path0/node_modules/next/dist/build/utils.js:1178:15
[18:10:11.392] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[18:10:11.392] type: 'Error'
[18:10:11.393] }
[18:10:11.489] Error: Command "npm run build" exited with 1


I suspected it was some error spefically with that vercel project so I created a new project and imported the same repository and it has no issue building, now I am a bit confused and I am not sure how to fix the original project. Anyone has any idea how to solve this?

1 Reply

Sloth bearOP
after some trial and error I noticed that it starts throwing the error when I change NEXT_PUBLIC_APP_URL from localhost to the Vercel URL, I am still trying to figure out why, but it probably is something that I am doing wrong...