Unable to deploy Qwik,js site: Internal Errror

Hello,

I’m experiencing the following error when deploying a Qwik.js site:
" The deployment failed due to an internal error. Retry deployment to restart the build process."

I don’t think it is an internal error - I’ve been trying for twelve hours without success. Here is the relevant info from the log:

10:58:23.056	✨ Upload complete!
10:58:24.692	Success: Assets published!
10:58:26.521	Error: Failed to publish your Function. Got error: Uncaught ReferenceError: global is not defined
  at functionsWorker-0.5625850033461508.js:27244:10

The site uses Mongoose to connect to MongoDB - would this be an issue as deployment worked fine when it was just a ‘static’ site with no db connections?

Qwik creates an entry.cloudflare-pages.tsx file which does reference ‘global’:

import { createQwikCity, type PlatformCloudflarePages } from '@builder.io/qwik-city/middleware/cloudflare-pages'
import qwikCityPlan from '@qwik-city-plan'
import { manifest } from '@qwik-client-manifest'
import render from './entry.ssr'

declare global {
    interface QwikCityPlatform extends PlatformCloudflarePages {}
}

const onRequest = createQwikCity({ render, qwikCityPlan, manifest })

export { onRequest }

Many thanks for any help!
Cheers, Matt

Ah, after a bit more research it seems I may not be able to use MongoDB Atlas / Mongoose with Cloudflare Pages - is this the case? If so, what would be go-to database solution for CF Pages?
Cheers, Matt