Skip to content

Commit

Permalink
Add server config for ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Aug 16, 2023
1 parent 5bcf758 commit 5815b28
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/subsocial-query/subsocial/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SUBSTRATE_URL } from '@/constants/subsocial'
import { getCrustIpfsAuth } from '@/utils/env/server'
import type { SubsocialApi } from '@subsocial/api'

export interface SubsocialConnectionConfig {
Expand All @@ -9,13 +10,24 @@ export interface SubsocialConnectionConfig {
}

// TODO: research better way to have this config set outside of this subsocial-query folder
let config: SubsocialConnectionConfig = {
const clientConfig: SubsocialConnectionConfig = {
substrateUrl: SUBSTRATE_URL,
ipfsNodeUrl: 'https://ipfs.subsocial.network',
ipfsAdminNodeUrl: 'https://gw.crustfiles.app',
}
const serverConfig: SubsocialConnectionConfig = {
substrateUrl: SUBSTRATE_URL,
ipfsNodeUrl: 'https://gw.crustfiles.app',
ipfsAdminNodeUrl: 'https://gw.crustfiles.app',
postConnectConfig: (api) => {
const headers = { authorization: `Bearer ${getCrustIpfsAuth()}` }
api.ipfs.setWriteHeaders(headers)
api.ipfs.setPinHeaders(headers)
},
}
export function getConnectionConfig() {
return config
if (typeof window === 'undefined') return clientConfig
return serverConfig
}

export interface TxCallbackInfo {
Expand Down

0 comments on commit 5815b28

Please sign in to comment.