Prerendering error when deploying next js, sanity project?

I have the following error usin Sanity cms with Next.js 13

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:14062:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetchPrices (/vercel/path0/.next/server/pages/index.js:581:17)
    at async getStaticProps (/vercel/path0/.next/server/pages/index.js:558:24)
info  - Generating static pages (3/3)

Export encountered errors on following paths:
    /
Error: Command "npm run build" exited with 1
Deployment completed
BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

Context:
I have “next”: “13.3.0”, “next-sanity”: “^4.1.7”, installed

.env.local:

  • NEXT_PUBLIC_SANITY_DATASET=production
  • NEXT_PUBLIC_SANITY_PROJECT_ID={projectID}
  • NEXT_PUBLIC_BASE_URL=http://localhost:3000/

build script package.json:
“build”: “next build && next export”,

I use pages folder structure not appDir

in pages:

  • api(folder)
  • _app.tsx
  • _document.tsx
  • index.tsx

next.config.js:

const nextConfig = {
  pageExtensions: ["mdx", "md", "jsx", "js", "tsx", "ts"],
  reactStrictMode: true,
};

module.exports = nextConfig;

If I do

npm run build

It build out fine, but when I do a commit neither netlify or vercel can’t deploy, I get the above error.
I also receive error if in env.local I use the prod url…

This is my local build:

Route (pages)                              Size     First Load JS
┌ ● / (390 ms)                             40.9 kB         114 kB
├   └ css/41abe3765720b937.css             851 B
├   /_app                                  0 B            73.6 kB
├ ○ /404                                   182 B          73.8 kB
├ λ /api/getPrices                         0 B            73.6 kB
└ λ /api/getQuote                          0 B            73.6 kB

Looks weird that both api endpoint is 0 B, but I have no clue at this point what is the issue.. Before I added Sanity cms to the project everything was fine, but now I can’t merge the cms implementation to master as the deployment fails…

deployment error:

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at packageData (node:internal/deps/undici/undici:6370:23)
    at specConsumeBody (node:internal/deps/undici/undici:6348:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetchPrices (/vercel/path0/.next/server/pages/index.js:582:18)
    at async getStaticProps (/vercel/path0/.next/server/pages/index.js:558:24)
info  - Generating static pages (3/3)
> Export encountered errors on following paths:
    /
Error: Command "npm run build" exited with 1
Deployment completed
BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

If any more context needed regarding my implementation let me know.