medusajs / nextjs-starter-medusa

A performant frontend ecommerce starter template with Next.js 14 and Medusa.
https://next.medusajs.com/
MIT License
1.64k stars 450 forks source link

Unhandled Runtime Error Error: Error: [object Object] #207

Open bhaveshselarka opened 10 months ago

bhaveshselarka commented 10 months ago

⚠ metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:8000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase ⨯ { error: 'fetch failed' } ⨯ [Error: Error: [object Object]] { digest: '193452068' } ⚠ ./node_modules/@medusajs/utils/dist/common/get-config-file.js

SCR-20231125-nrwk
Dalvae commented 9 months ago

I have the same problem, how do you solve it?

heejinp commented 9 months ago

I am having the same issue, did u solve? the error message is the same but with "Next.js (14.0.0) out of date"

image

molavec commented 9 months ago

In my case, Next required data from API (provided for another service in my localhost). Compile fails with this error if the service is not up.

salvinoto commented 9 months ago

In my case, Next required data from API (provided for another service in my localhost). Compile fails with this error if the service is not up.

Could you explain this more please, I'm trying to figure this out myself

DouglasMontoya commented 9 months ago

In my case, Next required data from API (provided for another service in my localhost). Compile fails with this error if the service is not up.

Could you explain this more please, I'm trying to figure this out myself

He means that you have to create the storefront but with the medusa backend running. I tried it like this and it worked for me.

salvinoto commented 9 months ago

In my case, Next required data from API (provided for another service in my localhost). Compile fails with this error if the service is not up.

Could you explain this more please, I'm trying to figure this out myself

He means that you have to create the storefront but with the medusa backend running. I tried it like this and it worked for me.

I see, what if I'm hosting it on railway? I tried putting the railway url under NEXT_PUBLIC_MEDUSA_BACKEND_URL, got nothing tho

SharadKumar commented 9 months ago

Errors: metadata.metadataBase is not set for resolving social open graph or twitter images They are fixed by exporting metadataBase from app/layout.tsx.

I sitll get failure with Vercel deployment:

Collecting page data ...
15:29:43.125 | Generating static pages (0/17) ...
15:29:43.470 | ⚠ Entire page /404 deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /404
15:29:43.475 | Generating static pages (4/17)
15:29:43.727 | ⚠ Entire page /checkout deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /checkout
15:29:43.728 | Generating static pages (8/17)
15:29:43.867 | ⚠ Entire page /account/orders deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/orders
15:29:43.868 | ⚠ Entire page /account deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account
15:29:43.868 | ⚠ Entire page /account/addresses deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/addresses
15:29:43.913 | Generating static pages (12/17)
15:29:43.913 | ⚠ Entire page /account/profile deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/profile
15:29:43.913 | ⚠ Entire page /cart deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /cart
15:29:43.946 | ⚠ Entire page /account/login deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/login
15:29:43.952 | ⚠ Entire page /store deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /store
15:29:43.967 | ⚠ Entire page / deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /
15:29:43.969 | { error: 'fetch failed' }
15:29:43.989 | { error: 'fetch failed' }
15:29:43.989 |  
15:29:43.989 | Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
15:29:43.989 | [object Object]
15:29:43.994 | ✓ Generating static pages (17/17)
15:29:44.008 |  
15:29:44.009 | > Export encountered errors on following paths:
15:29:44.009 | /(main)/page: /
15:29:44.096 | error Command failed with exit code 1.
15:29:44.097 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
15:29:44.113 | Error: Command "yarn run build" exited with 1

Although locally I see not problem with yarn build:

 Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (0/17)  [    ] ⚠ Entire page /404 deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /404
 ⚠ Entire page /account/login deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/login
 ⚠ Entire page /account/orders deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/orders
 ⚠ Entire page /cart deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /cart
 ⚠ Entire page /account deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account
 ⚠ Entire page /checkout deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /checkout
 ⚠ Entire page /account/profile deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/profile
 ⚠ Entire page /account/addresses deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /account/addresses
   Generating static pages (1/17)  [=   ] 
 ⚠ Entire page /store deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /store
 ✓ Generating static pages (17/17) 
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    
SharadKumar commented 9 months ago

ok the issue was just env var not being properly set in Vercel, as I had integrated Railway and overlooked one of the var was still missing in Vercel project!

Kofi-Emma commented 7 months ago

ok the issue was just env var not being properly set in Vercel, as I had integrated Railway and overlooked one of the var was still missing in Vercel project!

Having the same problem, which env did you not properly set in Vercel?

denisfelst commented 6 months ago

@SharadKumar what var was it? Would have helped to mention it.

@Kofi-Emma Did you solve it / find the var?

denisfelst commented 6 months ago

@salvinoto did you solve this?

denisfelst commented 6 months ago

@olivermrbl Hey Oliver, any idea what this could be? I'm stuck with this and having exactly the same issue as @SharadKumar on Vercel deployment (not locally)

VariableVic commented 6 months ago

Hey @denisfelst - like others mentioned, errors like this usually indicate a failing connection to the Medusa server. The crucial env var to set is NEXT_PUBLIC_MEDUSA_BACKEND_URL. Make sure it points to an active Medusa server, including the protocol but without a trailing slash. E.g.: https://my-medusa-server.herokuapp.com

Double check if your Medusa server is running and healthy by visiting <YOUR-SERVER-URL>/health. This should return OK.