@@ -311,13 +311,25 @@ async function loadCustomFont(input: { url: string; weight: 400 | 700 }) {
311
311
} ;
312
312
}
313
313
314
+ /**
315
+ * Temporary function to log some data on Cloudflare.
316
+ * TODO: remove this when we found the issue
317
+ */
318
+ function logOnCloudflareOnly ( message : string ) {
319
+ if ( process . env . DEBUG_CLOUDFLARE === 'true' ) {
320
+ // biome-ignore lint/suspicious/noConsole: <explanation>
321
+ console . log ( message ) ;
322
+ }
323
+ }
324
+
314
325
/**
315
326
* Fetch a resource from the function itself.
316
327
* To avoid error with worker to worker requests in the same zone, we use the `WORKER_SELF_REFERENCE` binding.
317
328
*/
318
329
async function fetchSelf ( url : string ) {
319
330
const cloudflare = getCloudflareContext ( ) ;
320
331
if ( cloudflare ?. env . WORKER_SELF_REFERENCE ) {
332
+ logOnCloudflareOnly ( `Fetching self: ${ url } ` ) ;
321
333
return await cloudflare . env . WORKER_SELF_REFERENCE . fetch (
322
334
// `getAssetURL` can return a relative URL, so we need to make it absolute
323
335
// the URL doesn't matter, as we're using the worker-self-reference binding
@@ -334,6 +346,9 @@ async function fetchSelf(url: string) {
334
346
async function readImage ( response : Response ) {
335
347
const contentType = response . headers . get ( 'content-type' ) ;
336
348
if ( ! contentType || ! contentType . startsWith ( 'image/' ) ) {
349
+ logOnCloudflareOnly ( `Invalid content type: ${ contentType } ,
350
+ status: ${ response . status }
351
+ rayId: ${ response . headers . get ( 'cf-ray' ) } ` ) ;
337
352
throw new Error ( `Invalid content type: ${ contentType } ` ) ;
338
353
}
339
354
0 commit comments