-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lucid requires leaking the blockfrost key if in a browser enviornment #25
Comments
I don't see it as a "big" issue. What would be your alternative approach? |
Are you fine then if community use your blockfrost API key? I think that it's worth to think about safer alternative |
I'm not sure. But it is indeed a problem, because other people can use your API key (spending your money) |
you could implement a proxy api call so instead use blockfrost url, you can use a custom rest api to your backend and then from there call blockfrost to get the data so you don't need to expose your project id to the front end |
This is the recommended way to do it. Create a serverless function for the proxy request. |
Could be for just testing, otherwise use it on nodejs as backend (https://github.com/blockfrost/blockfrost-js) |
According to @Traka-Dev's suggestion, I created an example repo for doing this with next.js: https://github.com/GGAlanSmithee/cardano-lucid-blockfrost-proxy-example It also handles multiple blockfrost projects (for different networks) and for switching between networks. Only implemented with the nami wallet for now, as a testbed. Please check it out. |
To add to this conversation, even if you proxy the Blockfrost API calls, there is nothing stopping an advesary from abusing your API endpoints and by extension you Blockfrost account. In similar services that I've used before - Infura and magic.link - they allow you to whitelist domains, which would solve both issues, because in that case, it does not mather if your API key is public. Until that is in place / if they don't implement it, you could use headers, like |
I got an answer from Blockfrost:
The information on the linked page more or less reaffirms what @Traka-Dev said |
This seems like a big issue in the library.
In order to use it in a browser environment, you need to leak your blockfrost API key in the frontend bundle.
The text was updated successfully, but these errors were encountered: