Skip to content

Commit

Permalink
Merge pull request #1727 from sushi-labs/drpc-jwt
Browse files Browse the repository at this point in the history
feat(apps/web): add drpc jwt
  • Loading branch information
LufyCZ authored Oct 15, 2024
2 parents a21b03a + 44ab30e commit 5943660
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/web/src/lib/wagmi/config/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,24 @@ const connectors = connectorsForWallets(
},
)

const drpcJwt = process.env['NEXT_PUBLIC_DRPC_JWT']

export const createProductionConfig = () => {
const transports = Object.entries(publicTransports).reduce(
(acc, [chainId, transport]) => {
const transportUrl = transport({ chain: undefined }).value?.url!

let fetchOptions = {}
if (drpcJwt) {
fetchOptions = {
headers: {
Authorization: drpcJwt,
},
}
}

acc[Number(chainId) as ChainId] = http(transportUrl, {
fetchOptions,
onFetchRequest(_req) {
if (typeof window !== 'undefined' && transportUrl.includes('drpc')) {
try {
Expand Down

0 comments on commit 5943660

Please sign in to comment.