mah51 / mikeroph.one

My website, made with NextJS and ChakraUI.

Home Page:https://mikeroph.one

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploy failure on vercel, at spotify endpoint

mah51 opened this issue · comments

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

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 :)

@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)

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:

  •   const { responseTracks, responseArtists, responseRecently } = await getSpotifyData()
    
  •   console.log('responseTracks: ', responseTracks);
      console.log('responseArtists: ', responseArtists);
      console.log('responseRecently: ', responseRecently);```
    
    

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!

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?

On build I get the same error as vercel

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

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 :)

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