From 00ee151e472c2cb6aeb9a552b761d0da8c5ca3eb Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Tue, 11 Jun 2024 21:04:28 +0700 Subject: [PATCH] perf: return cf-images --- services/image/src/routes/ipfs.ts | 10 +++++++++- services/image/src/utils/ipfs.ts | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/image/src/routes/ipfs.ts b/services/image/src/routes/ipfs.ts index d1f532c..9ef75dd 100644 --- a/services/image/src/routes/ipfs.ts +++ b/services/image/src/routes/ipfs.ts @@ -48,7 +48,15 @@ app.get('/*', async (c) => { }) if (publicUrl) { - return c.redirect(publicUrl, 301) + return fetch(publicUrl, { + cf: { + cacheTtlByStatus: { + '200-299': CACHE_DAY, + '404': 0, + '500-599': 0, + }, + }, + }) } } diff --git a/services/image/src/utils/ipfs.ts b/services/image/src/utils/ipfs.ts index 2bc6423..e5c15ef 100644 --- a/services/image/src/utils/ipfs.ts +++ b/services/image/src/utils/ipfs.ts @@ -39,6 +39,7 @@ export async function fetchIPFS({ path }: { path: string }) { const gateways: HTTPS_URI[] = [ ipfsProviders.ipfs, + ipfsProviders.dweb, ipfsProviders.filebase_kodadot, ]