Next.js Discord

Discord Forum

Ecommerce template - Dev serv works but Vercel build fails with error on prerendering page

Answered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hi!

It looks like something broke recently and I'm not quite sure of what really. When Vercel tries to build my page, I am receiving this error

  Creating an optimized production build ...
 ✓ Compiled successfully
   Skipping linting
   Checking validity of types ...
   Collecting page data ...
 ⚠ Using edge runtime on a page currently disables static generation for that page
   Generating static pages (0/14) ...
   Generating static pages (3/14) 
   Generating static pages (6/14) 

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

{
  cause: 'unknown',
  status: 500,
  message: 'Dynamic server usage: no-store fetch https://******.myshopify.com/api/2023-01/graphql.json /contact',
  query: '\n' +
    '  query getMenu($handle: String!) {\n' +
    '    menu(handle: $handle) {\n' +
    '      title\n' +
    '      items {\n' +
    '        title\n' +
    '        url\n' +
    '      }\n' +
    '    }\n' +
    '  }\n',
  digest: '1277875179'
}
{
  cause: 'unknown',
  status: 500,
  message: 'Dynamic server usage: no-store fetch https://*******.myshopify.com/api/2023-01/graphql.json /contact',
  query: '\n' +
    '  query getMenu($handle: String!) {\n' +
    '    menu(handle: $handle) {\n' +
    '      title\n' +
    '      items {\n' +
    '        title\n' +
    '        url\n' +
    '      }\n' +
    '    }\n' +
    '  }\n',
  digest: '1277875179'
}
Error occurred prerendering page "/contact". Read more: https://nextjs.org/docs/messages/prerender-error

 ✓ Generating static pages (14/14)
> Export encountered errors on following paths:
    /(static)/contact/page: /contact
    /(static)/terms/privacy/page: /terms/privacy
    /(static)/terms/terms-of-service/page: /terms/terms-of-service
    /page: /
    /wishlist/page: /wishlist


I can't understand the error quite. It looks like there's something wrong with the fetch towards the Shopify API, no?
Answered by Brown bear
Apparently I had the cache-option set to no-store on the shopifyFetch function. I reverted it back to force-cache and now everything works.
View full answer

7 Replies

@Brown bear Hi! It looks like something broke recently and I'm not quite sure of what really. When Vercel tries to build my page, I am receiving this error Creating an optimized production build ... ✓ Compiled successfully Skipping linting Checking validity of types ... Collecting page data ... ⚠ Using edge runtime on a page currently disables static generation for that page Generating static pages (0/14) ... Generating static pages (3/14) Generating static pages (6/14) Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error { cause: 'unknown', status: 500, message: 'Dynamic server usage: no-store fetch https://******.myshopify.com/api/2023-01/graphql.json /contact', query: '\n' + ' query getMenu($handle: String!) {\n' + ' menu(handle: $handle) {\n' + ' title\n' + ' items {\n' + ' title\n' + ' url\n' + ' }\n' + ' }\n' + ' }\n', digest: '1277875179' } { cause: 'unknown', status: 500, message: 'Dynamic server usage: no-store fetch https://*******.myshopify.com/api/2023-01/graphql.json /contact', query: '\n' + ' query getMenu($handle: String!) {\n' + ' menu(handle: $handle) {\n' + ' title\n' + ' items {\n' + ' title\n' + ' url\n' + ' }\n' + ' }\n' + ' }\n', digest: '1277875179' } Error occurred prerendering page "/contact". Read more: https://nextjs.org/docs/messages/prerender-error ✓ Generating static pages (14/14) > Export encountered errors on following paths: /(static)/contact/page: /contact /(static)/terms/privacy/page: /terms/privacy /(static)/terms/terms-of-service/page: /terms/terms-of-service /page: / /wishlist/page: /wishlist I can't understand the error quite. It looks like there's something wrong with the fetch towards the Shopify API, no?
American black bear
hello. Did you manage to fix this problem? I am having the same issue.
Brown bearOP
No unfortunately not. Unfortunately my latest PR was so large that I can't figure out what caused this. I remember upgrading the Next version to 14. Haven't tried downgrading back to 13. Are you having the same issue with the Shopify error? Or just the Error of prerendering the page?

I saw some stuff in this Issue, but not sure if it's related: https://github.com/vercel/next.js/issues/58576. Couldn't find anything in their related to my Shopify error atleast.
Brown bearOP
I disabled every function from the lib-folder regarding Shopify's fetch (e.g. getMenu, getProducts). Now it deploys. Anyone who has any idea why Shopify's fetches seems to fail?
Brown bearOP
Apparently I had the cache-option set to no-store on the shopifyFetch function. I reverted it back to force-cache and now everything works.
Answer