Baroshem / nuxt-medusa

🛍️ Medusa module for Nuxt
https://nuxt-medusa.vercel.app
MIT License
130 stars 10 forks source link

Deploying to CloudFlare pages gives a 500 #46

Open mohamnag opened 3 months ago

mohamnag commented 3 months ago

Version

nuxt-medusa: 0.5.0 nuxt: 3.12.2

Reproduction Link

Steps to reproduce

What is Expected?

What is actually happening?

I have an app that is already deployed to CloudFlare Pages and is using useFetch to interact with a Medusa backend.

app is built using npx nuxi build --preset=cloudflare_pages and the resulting dist folder is deployed using wrangler to CloudFlare.

I decided to switch the implementation with this module for a better type support however as soon as this module is activated by calling useMedusaClient on any page, I get a 500 (t.adapter || Rr.adapter) is not a function error back. CloudFlare Pages' function shows no logs so I can't really really see what is wrong.

is this module SSR compatible or is it using Axios underneath?

Baroshem commented 3 months ago

Hey there,

Thanks for reporting this issue! The module is indeed using axios but it comes with both a composable (that works on client side / ssr) and the server utility that is supposed to work specifically in the server side (like api endpoint).

The error you received is quite strange.

I have not updated this package in some time. Maybe that could be the issue to it, but I think that it is the first case in a long time for this module.

Do you maybe have some clue on what could be breaking it?

Can you maybe reproduce the error locally or with a different preset?

mohamnag commented 2 months ago

Sorry for the late response.

Locally its all fine, these just appear after I build and deploy to CloudFlare and I'm not really getting any logs there.

Honestly no idea what could be breaking it and I'm also lacking any deep knowledge about CloudFlare Worker's internals and how they relate to nuxt server runtime. In the mean time I just switched back to using useFetch and $fetch directly which is a bit unfortunate but works pretty well locally as well as in CF.

Baroshem commented 2 months ago

I see, thanks for additional details. I am happy that you have made it work.

I will try to find some time in the next few weeks to investigate it