#Has anyone succeeded deploying the new medusa-nextjs-starter template to Vercel?

29 messages · Page 1 of 1 (latest)

jagged hearth
#

I keep getting this error during deployment (even when using the vercel deploy button in the documentation)

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types ...
   Collecting page data ...
   Generating static pages (0/17) ...

   Generating static pages (4/17) 

   Generating static pages (8/17) 

   Generating static pages (12/17) 
{ error: 'Unexpected token < in JSON at position 0' }
{ error: 'Unexpected token < in JSON at position 0' }
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
[object Object]

 ✓ Generating static pages (17/17) 
> Export encountered errors on following paths:
    /(main)/page: /
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

wide lodge
jagged hearth
#

not yet. Somewhere today I'll continue debugging it, but it has something to do with an api call that's coming from the homepage.

wide lodge
heavy trellis
wide lodge
heavy trellis
#

I think the latest storefront has a lot of issues that need to be fixed

wide lodge
delicate sentinel
#

I'll use the old version first

worldly wasp
wide lodge
ocean tartan
#

I think what's happening here is that the home page is being statically pre-rendered and since there is product data in the home page, it's trying to make a fetch to the product API. It works for me on localhost abut not on Vercel. I suspect there is some variable somewhere still hardcoded and pointing to localhost.

#

Like you @wide lodge I tried turning off the new product module by deleting the src/app/api folder and not specifying a POSTGRES_URL environment variable. I'm not really sure how to tell if that "worked" and turned off the product module or not.

ocean tartan
#

@wide lodge have you tried switching to node 18? Seems to have worked for me , at least on localhost. Tetsing Vercel soon.

wide lodge
#

@ocean tartan yeah that sounds about right. I’ll have to look more when I get home . I am using node 18 locally and it works perfectly there

ocean tartan
#

I think by default Vercel defaults to node 18 but just double check to make sure that's the case for you. I've got it working on my end.

wide lodge
storm jetty
#

@wide lodge were you able to fix the issue?

wide lodge
wide lodge
# storm jetty <@893641408970375199> were you able to fix the issue?

Someone found a quick solution for this. They just commented out one line, you can find it here https://github.com/medusajs/nextjs-starter-medusa/issues/210

GitHub

Hey, Thanks for the great template and Medusa in general! Everything works great locally but when trying to deploy the latest frontend/storefront on Vercel I keep running into an unexpected JSON er...

ocean tartan
#

Maybe worth doing a PR to fix this for everyone?

subtle kernel
#

It looks like you haven't set NEXT_PUBLIC_MEDUSA_BACKEND_URL

shy leaf
#

I succeeded by removing the / at the end of NEXT_PUBLIC_MEDUSA_BACKEND_URL.

humble pecan
#

Same error, cors are perfect I triple checked and I get products when commenting the line mencioned above.

#

But I still cant get products on main Page

humble pecan
#

Anything on this error? or should i go back to the last version of storefront?+

rustic sequoia
#

is it set correctly

humble pecan
#

it was correct, i was using a custom rule on cloudflare. my bad