diff --git a/.env.example b/.env.example
index d89b51a6..089d7c23 100644
--- a/.env.example
+++ b/.env.example
@@ -9,5 +9,6 @@ NEXT_PUBLIC_DISCORD_LINK="https://discord.gg/9XscSqJEq4"
NEXT_PUBLIC_GITHUB_LINK="https://github.com/Crossbell-Box/xlog"
NEXT_PUBLIC_CSB_IO=
NEXT_PUBLIC_CSB_SCAN="https://scan.crossbell.io"
+NEXT_PUBLIC_IPFS_GATEWAY="https://cf-ipfs.com/ipfs/"
REDIS_URL=
\ No newline at end of file
diff --git a/deploy/env.production b/deploy/env.production
index 98eb0642..4345812c 100644
--- a/deploy/env.production
+++ b/deploy/env.production
@@ -6,4 +6,5 @@ NEXT_PUBLIC_DISCORD_LINK=APP_NEXT_PUBLIC_DISCORD_LINK
NEXT_PUBLIC_GITHUB_LINK=APP_NEXT_PUBLIC_GITHUB_LINK
NEXT_PUBLIC_CSB_IO=APP_NEXT_PUBLIC_CSB_IO
NEXT_PUBLIC_CSB_SCAN=APP_NEXT_PUBLIC_CSB_SCAN
+NEXT_PUBLIC_IPFS_GATEWAY=APP_NEXT_PUBLIC_IPFS_GATEWAY
REDIS_URL=APP_NEXT_REDIS_URL
diff --git a/deploy/prod/secrets.yaml b/deploy/prod/secrets.yaml
index fad8d7cd..7966fbb4 100644
--- a/deploy/prod/secrets.yaml
+++ b/deploy/prod/secrets.yaml
@@ -7,6 +7,7 @@ stringData:
NEXT_PUBLIC_GITHUB_LINK: "https://github.com/Crossbell-Box/xlog"
NEXT_PUBLIC_CSB_IO: ""
NEXT_PUBLIC_CSB_SCAN: "https://scan.crossbell.io"
+ NEXT_PUBLIC_IPFS_GATEWAY: "https://cf-ipfs.com/ipfs/"
REDIS_URL: ${REDIS_URL}
kind: Secret
metadata:
diff --git a/src/components/common/BlockchainInfo.tsx b/src/components/common/BlockchainInfo.tsx
index 99577a24..edf0f00d 100644
--- a/src/components/common/BlockchainInfo.tsx
+++ b/src/components/common/BlockchainInfo.tsx
@@ -1,4 +1,4 @@
-import { CSB_SCAN } from "~/lib/env"
+import { CSB_SCAN, IPFS_GATEWAY } from "~/lib/env"
import { UniLink } from "../ui/UniLink"
import { Profile, Note } from "~/lib/types"
import { Disclosure } from "@headlessui/react"
@@ -87,9 +87,7 @@ export const BlockchainInfo: React.FC<{
{page
? page.related_urls
- ?.filter((url) =>
- url.startsWith("https://gateway.ipfs.io/ipfs/"),
- )
+ ?.filter((url) => url.startsWith(IPFS_GATEWAY))
.map((url) => {
return (
- {url.replace(
- "https://gateway.ipfs.io/ipfs/",
- "ipfs://",
- )}
+ {url.replace(IPFS_GATEWAY, "ipfs://")}
)
})
@@ -113,7 +108,7 @@ export const BlockchainInfo: React.FC<{
className="inline-block mr-4 break-all"
href={site?.metadata?.uri.replace(
"ipfs://",
- "https://gateway.ipfs.io/ipfs/",
+ IPFS_GATEWAY,
)}
key={site?.metadata?.uri}
>
diff --git a/src/components/ui/Avatar.tsx b/src/components/ui/Avatar.tsx
index 72ad4d21..93bc5d86 100644
--- a/src/components/ui/Avatar.tsx
+++ b/src/components/ui/Avatar.tsx
@@ -1,5 +1,6 @@
import clsx from "clsx"
import React, { useMemo } from "react"
+import { IPFS_GATEWAY } from "~/lib/env"
export const Avatar: React.FC<
{
@@ -22,7 +23,9 @@ export const Avatar: React.FC<
const image = useMemo(() => {
for (const image of images) {
if (image)
- return image.replace("ipfs://", "https://gateway.ipfs.io/ipfs/")
+ return image
+ .replace("ipfs://", IPFS_GATEWAY)
+ .replace("https://gateway.ipfs.io/ipfs/", IPFS_GATEWAY)
}
}, [images])
diff --git a/src/hooks/useUploadFile.ts b/src/hooks/useUploadFile.ts
index ee90c4c0..b857d1a8 100644
--- a/src/hooks/useUploadFile.ts
+++ b/src/hooks/useUploadFile.ts
@@ -1,5 +1,6 @@
import { useCallback } from "react"
import { Web3Storage } from "web3.storage"
+import { IPFS_GATEWAY } from "../lib/env"
export const useUploadFile = () => {
const uploadFile = useCallback
(async (blob, filename) => {
@@ -14,7 +15,7 @@ export const useUploadFile = () => {
wrapWithDirectory: false,
})
return {
- key: `https://gateway.ipfs.io/ipfs/${cid}`,
+ key: `${IPFS_GATEWAY}${cid}`,
}
}, [])
diff --git a/src/lib/crossbell.ts b/src/lib/crossbell.ts
index 0be89e33..46a9d2d0 100644
--- a/src/lib/crossbell.ts
+++ b/src/lib/crossbell.ts
@@ -1,4 +1,7 @@
-import { Contract, Indexer } from "crossbell.js"
+import { Contract, Indexer, Network } from "crossbell.js"
+import { IPFS_GATEWAY } from "../lib/env"
+
+Network.setIpfsGateway(IPFS_GATEWAY)
const indexer = new Indexer()
diff --git a/src/lib/env.ts b/src/lib/env.ts
index 00fe0e1e..16cdbac4 100644
--- a/src/lib/env.ts
+++ b/src/lib/env.ts
@@ -9,4 +9,7 @@ export const APP_DESCRIPTION = process.env.APP_DESCRIPTION
export const DISCORD_LINK = process.env.NEXT_PUBLIC_DISCORD_LINK
export const GITHUB_LINK = process.env.NEXT_PUBLIC_GITHUB_LINK
export const CSB_IO = process.env.NEXT_PUBLIC_CSB_IO
-export const CSB_SCAN = process.env.NEXT_PUBLIC_CSB_SCAN
+export const CSB_SCAN =
+ process.env.NEXT_PUBLIC_CSB_SCAN || "https://scan.crossbell.io"
+export const IPFS_GATEWAY =
+ process.env.NEXT_PUBLIC_IPFS_GATEWAY || "https://cf-ipfs.com/ipfs/"
diff --git a/src/lib/unidata.ts b/src/lib/unidata.ts
index 34ec1f1a..88c3f57e 100644
--- a/src/lib/unidata.ts
+++ b/src/lib/unidata.ts
@@ -1,5 +1,8 @@
import Unidata from "unidata.js"
+import { IPFS_GATEWAY } from "../lib/env"
-let unidata = new Unidata()
+let unidata = new Unidata({
+ ipfsGateway: IPFS_GATEWAY,
+})
export default unidata
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index aff05e0d..cba49c79 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -14,7 +14,7 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"
import { createIDBPersister } from "~/lib/persister.client"
import { connectorsForWallets, wallet } from "@rainbow-me/rainbowkit"
-import { CSB_SCAN } from "~/lib/env"
+import { CSB_SCAN, IPFS_GATEWAY } from "~/lib/env"
import "@rainbow-me/rainbowkit/styles.css"
@@ -27,8 +27,7 @@ const { chains, provider } = configureChains(
rpcUrls: {
default: "https://rpc.crossbell.io",
},
- iconUrl:
- "https://gateway.ipfs.io/ipfs/QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t",
+ iconUrl: `${IPFS_GATEWAY}QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t`,
nativeCurrency: {
decimals: 18,
name: "Crossbell Token",