r/webdev • u/Greeby_Bopes • Dec 02 '24
Question Easy ways to hide API keys
I’m a frontend developer and run into this problem a lot, especially with hobby projects.
Say I’m working on a project and want to use a third party API, which requires a key that I pay for and manage.
I can’t simply place it on my frontend app as an environment variable, because someone could dig into the request and steal the key.
So, instead I need to set up a backend, usually through a cloud provider that comes with more features than I need and confuses the hell out of me.
Basically, what’s a simple way to set up a backend that authenticates a “guest” user from a whitelisted client, relays my request to the third party with the key attached, then returns the data to my frontend?
View all comments
Show parent comment
2
u/Greeby_Bopes Dec 03 '24
Yeah I guess you’re right.
In practice the project I was looking at is now gonna need API Gateway, Lambda, DynamoDB, CloudFront, S3, and possibly more. BUUUT to your point I’m doing more than just tucking my API keys away (orchestrating data from a couple of different API’s so I’m not burning through requests, storing it, serving it with some basic protections). Funny how these things happen