-
Hi! I have a security concern about the provider api key and whether it's safe to set them in the frontend: If I have to type: Then variable thanks in advance!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Actually, it's not safe at all unless there is some white-listing applied. For e.g. Alchemy allows white-listing by contract address, so "eth_call" things would only work for certain contracts and someone can't just steal your API key and plug in their app which has to work with a different contract. Also, there is a domain white-list in Alchemy, so if a request is coming from a different domain, it would give a CORS error, however, this kind of protection can be bypassed from the backend, but still, it's good to have. If you have an API key from a service that does not provide a white-listing feature, then you should have a backend that acts as a proxy and only allow certain kind of requests, so that the API key cannot be used by someone else. If you are using next js, you might be able to use the serverless APIs, I think they are very useful in the sense that you don't have to manage a backend server for proxy and infrastructure services like vercel, netlify handle it for you. |
Beta Was this translation helpful? Give feedback.
Actually, it's not safe at all unless there is some white-listing applied. For e.g. Alchemy allows white-listing by contract address, so "eth_call" things would only work for certain contracts and someone can't just steal your API key and plug in their app which has to work with a different contract. Also, there is a domain white-list in Alchemy, so if a request is coming from a different domain, it would give a CORS error, however, this kind of protection can be bypassed from the backend, but still, it's good to have.
If you have an API key from a service that does not provide a white-listing feature, then you should have a backend that acts as a proxy and only allow certain kind of requ…