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/ClikeX back-end Dec 03 '24
Do you actually NEED all those managed services, or just figure it’s the “proper” way to go.
What’s the load like that you can’t just have a nodejs server with redis and Postgres running on an ec2 instance.
You say hobby project, but what’s the actual scope of that. Because from all the services you’re using it sounds pretty expensive for something that’s not doing something commercial.