From 11f5ace4ded5570dd618c8e3db143f7defbdb6ee Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Thu, 4 Jul 2024 18:46:57 +0200 Subject: [PATCH] fix: api key fallback --- web/netlify/functions/authUser.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/netlify/functions/authUser.ts b/web/netlify/functions/authUser.ts index 353e7a3e8..8c4b18cd3 100644 --- a/web/netlify/functions/authUser.ts +++ b/web/netlify/functions/authUser.ts @@ -74,8 +74,10 @@ const authUser = async (event) => { } try { + // If the main Alchemy API key is permissioned, it won't work in a Netlify Function so we use a dedicated API key + const alchemyApiKey = process.env.ALCHEMY_FUNCTIONS_API_KEY ?? process.env.ALCHEMY_API_KEY; const alchemyChain = isProductionDeployment() ? "arb-mainnet" : "arb-sepolia"; - const alchemyRpcURL = `https://${alchemyChain}.g.alchemy.com/v2/${process.env.ALCHEMY_FUNCTIONS_API_KEY}`; + const alchemyRpcURL = `https://${alchemyChain}.g.alchemy.com/v2/${alchemyApiKey}`; const provider = new ethers.providers.JsonRpcProvider(alchemyRpcURL); await siweMessage.verify({ signature, nonce: nonceData.nonce, time: new Date().toISOString() }, { provider }); } catch (err) {