#SSR not working on cloudflare with storyblok/astro package.

7 messages · Page 1 of 1 (latest)

grave shuttle
#

Has anybody been able to get SSR to run with cloudflare adapter, with storyblok? Basically what is happening with my application is that I have:
output: 'server', adapter: cloudflare(), in my config, and I am using the storyblok/astro package ("<@&1055234544183287879>/cloudflare": "^6.1.2", "@storyblok/astro": "^2.0.3", "astro": "^2.0.10"). When running my application on Cloudflare Pages the site loads successfully once, but after a refresh I get an error (picture). When looking into the Cloudflare logs it basically only gives me 'Page generates no response'. I have tried to remove parts of my code and it seems that there is some problem with the storyblok/astro package, because plain html in astro page works fine. But adding something simple like await storyblokApi.get('cdn/stories', {version: 'draft', }) results in the error again. Has anybody encountered something like this?

lone anchor
# grave shuttle Has anybody been able to get SSR to run with cloudflare adapter, with storyblok?...

you could put a .catch(err) { console.log (err) } sort of thing on that trial fetch, then look in the Cloudflare log. Should always have a catch with good handling anyway 🙂

Could it be you're not up to latest versions on Astro, integrations & adaptors? @pastel parrot has very recently upgraded to assure Storyblok has a needed polyfill for fetch, required at least on Netlify, though Cloudflare seems to say they provided a fetch implementation for workers.

If that's the cause, and not something in your fetch arguments that the .catch should disclose, there's also a polyfill you could try temporarily, called isomorphic-fetch . Read to see how (easily) to apply it, and report if you find this is the cover for your fault, thanks!

grave shuttle
#

Hello👋. I already tried installing the isomorphic-fetch but it didnt help. Will try adding .catch() to see if i get a different error.

grave shuttle
#

adding catch didnt help

#

I still dont know why it breaks

#

However i found out that it happens only on cloudflare SSR when i use storyblok client js

#

Refactored all pages to use ofetch with storyblok api v2 and everything was working as it should