So the thing is, by using React I see no way not to expose my API KEY. Is there any best practices on how to store it? Is it dangerous if someone will inspect my code and find this API key? How people solving this problem?
1 Answer
Is it dangerous if someone will inspect my code and find this API key? How people solving this problem?
There is no way around this problem and your API keys will always leak.
If you want to mitigate the issue you can create your special server that proxies requests to Alchemy and then manually control IP bans and such.
-
1
-
Yes, it is trivial ,because any one can check the API key from Web developer tools directly in Networks tab. There is no point to obfuscate. Commented Jun 29, 2022 at 11:14
-
1Almost all RPC API providers have a Domain restrictions, just set Domain(s) in the admin panel (Alchemy, Infura … etc) and you will not need to hide your KEY.– ArchiCommented Jun 29, 2022 at 18:32
-
Note that domain restriction does not help much, as the most of the API key abuse is server-side and server-side clients can set the domain to any value they wish. Commented Jun 30, 2022 at 7:25