Skip to content

Commit

Permalink
add proxied pinata ipfs gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant committed Jul 9, 2024
1 parent 912de66 commit a1bfba6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ OPTIMISM_RPC_PASSWORD=

MORALIS_API_KEY=

SUBGRAPH_STUDIO_API_KEY=
SUBGRAPH_STUDIO_API_KEY=

PINATA_GATEWAY_URL=
PINATA_GATEWAY_KEY=
21 changes: 21 additions & 0 deletions src/routes/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ const generateChainRoutes = (router: Router) => {
},
}),
);

if (
process.env.PINATA_GATEWAY_URL === undefined ||
process.env.PINATA_GATEWAY_KEY === undefined
) {
console.warn("PINATA env vars are not set");
}

router.use(
"/ipfs",
createProxyMiddleware({
target: process.env.PINATA_GATEWAY_URL,
changeOrigin: true,
pathRewrite: {
[`^/api/v1/ipfs`]: "/ipfs",
},
headers: {
"x-pinata-gateway-token": process.env.PINATA_GATEWAY_KEY || "",
},
}),
);
}
};

Expand Down

0 comments on commit a1bfba6

Please sign in to comment.