diff --git a/packages/qwik-city/middleware/cloudflare-pages/index.ts b/packages/qwik-city/middleware/cloudflare-pages/index.ts index ab033bd6185..9a00ff789e0 100644 --- a/packages/qwik-city/middleware/cloudflare-pages/index.ts +++ b/packages/qwik-city/middleware/cloudflare-pages/index.ts @@ -15,7 +15,11 @@ import { setServerPlatform } from '@builder.io/qwik/server'; /** @public */ export function createQwikCity(opts: QwikCityCloudflarePagesOptions) { - if (typeof globalThis.TextEncoderStream === 'undefined') { + try { + // https://developers.cloudflare.com/workers/configuration/compatibility-dates/#streams-constructors + // this will throw if CF compatibility_date < 2022-11-30 + new globalThis.TextEncoderStream(); + } catch (e) { (globalThis as any).TextEncoderStream = TextEncoderStream; } const qwikSerializer = {