mah51 / mikeroph.one

My website, made with NextJS and ChakraUI.
https://mikeroph.one
MIT License
198 stars 25 forks source link

Deploy failure on vercel, at spotify endpoint #24

Closed mah51 closed 2 years ago

mah51 commented 2 years ago

Error occurred prerendering page "/spotify". Read more: https://nextjs.org/docs/messages/prerender-error

10:41:26.628 | FetchError: invalid json response body at https://vercel.com/login?next=%2Fdeployments%2Fportfolio-v5-real-or7cio91c-orangemn6.vercel.app%3Fhost%3Dportfolio-v5-real-or7cio91c-orangemn6.vercel.app%26redirect%3D1%26section%3D reason: Unexpected token < in JSON at position 0 10:41:26.629 | at /vercel/path0/node_modules/node-fetch/lib/index.js:272:32 10:41:26.629 | at processTicksAndRejections (internal/process/task_queues.js:95:5) 10:41:26.629 | at async getStaticProps (/vercel/path0/.next/server/pages/spotify.js:436:16) 10:41:26.632 | at async renderToHTML (/vercel/path0/node_modules/next/dist/server/render.js:329:24) 10:41:26.633 | at async /vercel/path0/node_modules/next/dist/export/worker.js:273:36 10:41:26.633 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20) 10:41:26.682 | info - Generating static pages (8/11) 10:41:27.726 | info - Generating static pages (11/11) 10:41:27.729 |
10:41:27.729 | > Build error occurred 10:41:27.731 | Error: Export encountered errors on following paths: 10:41:27.731 | /spotify 10:41:27.732 | at /vercel/path0/node_modules/next/dist/export/index.js:487:19 10:41:27.732 | at runMicrotasks () 10:41:27.732 | at processTicksAndRejections (internal/process/task_queues.js:95:5) 10:41:27.733 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20) 10:41:27.733 | at async /vercel/path0/node_modules/next/dist/build/index.js:833:17 10:41:27.733 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20) 10:41:27.734 | at async /vercel/path0/node_modules/next/dist/build/index.js:707:13 10:41:27.734 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20) 10:41:27.734 | at async Object.build [as default] (/vercel/path0/node_modules/next/dist/build/index.js:77:25) 10:41:27.790 | Error: Command "npm run build" exited with 1

mah51 commented 2 years ago

Just to do the inital check, have you assigned your environment variables shown in the .env.example file on the vercel dashboard? If so how did you go about getting the spotify refresh token... Thanks :)

orangemn6 commented 2 years ago

Yes I did. I got the token using https://getyourspotifyrefreshtoken.herokuapp.com/

orangemn6 commented 2 years ago

@mah51 I updated the .env to include my next_public_host and now the error changed a bit.


Error occurred prerendering page "/spotify". Read more: https://nextjs.org/docs/messages/prerender-error
--
11:29:51.856 | FetchError: invalid json response body at https://www.orangemn6.xyz/api/get-spotify-data reason: Unexpected token < in JSON at position 0
11:29:51.856 | at /vercel/path0/node_modules/node-fetch/lib/index.js:272:32
11:29:51.856 | at processTicksAndRejections (internal/process/task_queues.js:95:5)
11:29:51.856 | at async getStaticProps (/vercel/path0/.next/server/pages/spotify.js:436:16)
11:29:51.856 | at async renderToHTML (/vercel/path0/node_modules/next/dist/server/render.js:329:24)
11:29:51.856 | at async /vercel/path0/node_modules/next/dist/export/worker.js:273:36
11:29:51.857 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20)

Error occurred prerendering page "/spotify". Read more: https://nextjs.org/docs/messages/prerender-error
--
11:29:51.856 | FetchError: invalid json response body at https://www.orangemn6.xyz/api/get-spotify-data reason: Unexpected token < in JSON at position 0
11:29:51.856 | at /vercel/path0/node_modules/node-fetch/lib/index.js:272:32
11:29:51.856 | at processTicksAndRejections (internal/process/task_queues.js:95:5)
11:29:51.856 | at async getStaticProps (/vercel/path0/.next/server/pages/spotify.js:436:16)
11:29:51.856 | at async renderToHTML (/vercel/path0/node_modules/next/dist/server/render.js:329:24)
11:29:51.856 | at async /vercel/path0/node_modules/next/dist/export/worker.js:273:36
11:29:51.857 | at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:60:20)
mah51 commented 2 years ago

If you could run this on your local machine and add the following lines of code in /pages/api/get-spotify-data.ts that would be great thanks:

At line 9:

Then see what output you are getting... It has been a while since I have worked on this project sorry :o. If this doesnt run properly then please go to /utils/spotify.ts and console.log the response from each api endpoint like so and see if it logs: image

Thanks!

orangemn6 commented 2 years ago

So after trying the first one, it compiles on my local machine but stays at not playing. I have spotify open playing a playlist currently. I get no console output except for building. Should I try the second one?

orangemn6 commented 2 years ago

On build I get the same error as vercel

mah51 commented 2 years ago

Okay that's weird... No output in the terminal where you are running it from?

mah51 commented 2 years ago

You can add me on discord at Mikerophone#0001 if you have it, might be faster to sort this out... Ill post the solution here after :)

orangemn6 commented 2 years ago

Yeah I can add you there if it is easier. My discord is RandomTC