Closed xdabuss closed 10 months ago
Hi,
That sounds very strange indeed. AFAIK @kyunal also deploys the Remix storefront to CF Pages? Did you ever run into anything like this?
Hi, this is a very strange issue indeed, and to me it looks like a race condition on cold starts like you elaborated. I have an idea to mitigate this, which is to use the createPagesFunctionHandler
function to properly inject/set the API_URL based on the cloudflare context.
I will try to get this fixed in the coming days and also address your issue in https://github.com/vendure-ecommerce/storefront-remix-starter/issues/60
Hi, I wasn't able to reproduce the issue, but the linked commit should hopefully fix it. The onRequest handler runs before everything else, so hopefully it can set the API URL correctly.
Thanks Timur! I'll let you know if the issue persists
Hi all. Been running into an issue after deploying this site on CloudFlare. Wanted to share in case anyone else runs into this. because it really had me scratching my head. Any maybe there's a way we can patch this up (unless this is just a "me" issue - I am a backend dev new to frontend development)
I had my own instance of vendure api running on a cloud url. When I would leave the storefront tab inactive for ~30 secs to a minute, and then came back and pressed a button for one of my own categories (eg jackets), I would get a 404.
Then, I would refresh the page and everything would start working again. Now, I think this is because when deployed on CFWorkers, due to their serverless nature, the worker shuts down after some inactivity. When hitting a GQL call from "cold start", the Remix application seems to be loading in the
API_URL
in here in such a way that theDEMO_API_URL
gets loaded, therefore causing problems and sometimes 404s (since demo api doesn't have some resources that my api has).It seems that the API_URL gets set here usually, but not on the cold starts for some reason.
I hacked around this by setting
DEMO_API_URL
to my actual API url, and all is working as intended now. Anyone have thoughts on this or experience the same problem? Perhaps there is a better fix or maybe I'm misunderstanding something.