How to Hide API Keys with Node JS | Hiding API Keys with dotenv Environment Variables

preview_player
Показать описание

Learn how to Hide API Keys with Node JS. Hiding API Keys with dotenv environment variables is possible in server-side Node JS. That's why setting up a Node JS API Key Relay allows you to hide API keys and still receive the API data you need.

(0:00) Intro
(1:25) Install NodeJS
(3:13) Install Package Dependencies
(6:59) Create the API
(9:49) Test a Route
(10:07) Create the Weather API Route
(13:05) Add an environment variable with dotenv
(14:37) Create GET and POST Weather Routes
(19:40) Test the GET and POST Dev Routes
(23:14) Add a Rate Limiter
(25:05) Protecting Your Routes
(28:58) Your .gitignore file
(29:29) Pulling the code from GitHub to Glitch
(31:14) Testing the Live Glitch Routes

✅ Follow Me:

Was this tutorial about how to hide API keys with a Node JS Relay helpful? If so, please share. Let me know your thoughts in the comments.

#hide #api #keys
Рекомендации по теме
Комментарии
Автор

Wow, I learned more in 30 minutes than with months of crappy codecademy lessons

avshinkampf
Автор

Hi Dave,
Just to say thanks allot for this well explained video, just about to use it now to implement this solution. Really well thought out and enjoy the pace as well, as i embark to putting this in for a web app that requires 3 API`s! 😅
Also last but not least just a quick shout out to all those using NodeJS V18 and above, that ' require ("node-fetch" ' is not needed as it is built in from now onwards. 👍

marksheard
Автор

damn Dave does it again. So simple, so powerful, so awesome. You’re f*kn phenomenal dude. Been watching for a while, Keep up the great vids!

codedev
Автор

Thank you Dave for this wonderful tutorial~! It helps me a lot!! Thx again!

minsupark
Автор

excellent tutorial! everything is working out now! thanks

djmg
Автор

Damn Dave, you think and write code faster than GPT4 👏

Speedfighter
Автор

Hi Dave. Brilliant video. I struggle a bit with sending my post request body. I can’t grasp how to send information inputted from my html <input> element to my api. Like typing and name of a city and then searching for weather data for it. Any ideas on that? Need to be a post request unfortunately.

stoyansarov
Автор

Are we able to just write something like console.log(API_KEY) and it will write the api key ?

drrooz
Автор

Dave this started off so good, but I just need to hide the api key - that's it. I can't figure out how to get around the search request you added. : (

jamesmassa
Автор

A few times, you mention that you want to make the code "dry". What do you mean? The second time it was mentioned was around the 19 minute mark.

JohnDavis_NetSkink_Computing
Автор

Awesome - I have watched this a few times now to digest everything. However, is CORS really enough to secure this new back-end endpoint? If a malicious actor wants to use your API from their own Postman or other non-origin script, what's to stop them? Thanks in advance for any guidance!

mikegesme
Автор

Random question...where did you get the "strive for progress..." sign? I seriously need to remind myself this everyday.

MrSxiong
Автор

Can this method be used to hide an AWS API KEY in an HTML file?

coneeded
Автор

Brother it's cool, I mean in react server ( not local host server) .env not working so that's why this way is very cool, but in recat first i creat .env file and write code
Then my index.js folder call it like then I push it GitHub still show .env file in GitHub account that's why in . gitignore file add .env file after that I push it's work fine so my first question is which code i use I mean with .env and . gitignore method or today video you show that's way ??
My 2nd question is in index.html page action tag use some api key so that's key how to hide using .env beacuse it not react project so I can't do that pls help ??

sportsstimulant
Автор

big lack of explanations in first part

consciencedimension