How to hide your API keys SAFELY when using React

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024
  • ⭐ Sign up for my Full Stack Developer Course: www.codewithan...
    In this video I show you how to store your API keys safely for your React Project, by building out a mini backend using Node.js. This video is a part 2, to building a Crypto App in React where we store our API keys on the frontend.
    Final code available here: github.com/kub...
    Watch Part 1 here: • API Project! Build a C...
    Watch part 3: Auth and limiting Requests - coming soon
    ___
    ⭐ Check out my IDE here and get 1 month free: jb.gg/get_webs...
    ⭐ New to code and none of this is making sense? Watch my '12hr+ TH-cam Coding Bootcamp' in which you will learn HTML, CSS and JavaScript Fundamentals completely from scratch. It's on my channel and its 100% free.
    ⭐ In most videos I use Tabnine as my A.I autocompletion tool. You can download it for free here (I get no commission from this link, but am in a partnership): bit.ly/tabnine-...
    ⭐ You can get a blockchain domain with my affiliate link here: bit.ly/get-a-cr...
    ⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : www.buymeacoff...
    ⭐ Sign up for weekly coding tips from my newsletter partnership: bit.ly/JS-tips
    You can also find me on:
    Twitter: / ania_kubow
    Instagram: / aniakubow
    #codingbootcamp​ #coding

ความคิดเห็น • 280

  • @tumpelo22
    @tumpelo22 2 ปีที่แล้ว +34

    Doesn't app.listen() accept the PORT constant, or why do you put it as number 8000 if it is already defined as constant :P

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +51

      Oh no oooooops! Good catch! You are 100 percent right, I clearly wasn’t paying attention hahah. I will pin this so people know not to bother writing 8000 when you can just use the constant PORT. 🙌🙌

  • @jamesdouglaswhite
    @jamesdouglaswhite 2 ปีที่แล้ว +38

    Extremely useful tutorial, thank you. Finally someone who understands a newbie's need for explanation of the fundamentals that seem so confusing when trying to figure it out for ourselves.

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +4

      Thank you so much!!

    • @LorenzoJimenez
      @LorenzoJimenez 2 ปีที่แล้ว

      @@aniakubow Well deserved!

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +3

      @@LorenzoJimenez thanks so much 😄😄

  • @owenwexler7214
    @owenwexler7214 2 ปีที่แล้ว +14

    This video is mandatory viewing for anyone making a frontend web app that connects to an API or backend of any sort.
    Remember guys: the best way to store secrets and credentials in your frontend is to NEVER EVER store secrets and credentials in your frontend.

  • @LorenzoJimenez
    @LorenzoJimenez 2 ปีที่แล้ว +35

    Very nice, you created a proxy. I know that is just an example, but I prefer to separate the proxy code in another project. Then add security rules that your API can only be called from your domain, and other measures to avoid denial of service attacks.

    • @Zzaa01
      @Zzaa01 2 ปีที่แล้ว +2

      This is great advice for this newbie!!

    • @katiechurchwell7463
      @katiechurchwell7463 2 ปีที่แล้ว

      cool!

  • @nicoladc
    @nicoladc 2 ปีที่แล้ว +32

    Really good tutorial, however I find missleading to say that this will prevent someone from using the paid API and use your money.
    This will only secure your API key, but if someone calls you API thousands of times you will still have the same problem, even if you didn't compromise you API key.
    If you really have a paid service behind an API I would strongly recommend to limit its use with throtling and user authentication, unless you are willing to take the risk of getting unusual traffic.
    Really good tutorial :)

    • @juandavidlandazabal5974
      @juandavidlandazabal5974 2 ปีที่แล้ว +2

      Just adding a origin cors in the server side is enough to avoid this issue, so only from your own domain you can call the API

    • @MarcStober
      @MarcStober 2 ปีที่แล้ว +14

      CORS prevents people from being scammed when they’re using a browser. However it doesn’t prevent someone malicious from calling your API outside of the browser. Overall it’s a good tutorial but it should mention there is more needed to be completely secure.

    • @salehaleit1501
      @salehaleit1501 ปีที่แล้ว

      rate-limiting is fairly simple to implement with express, for bigger scale applications a WAF such as Cloudflare are very good solutions

  • @abhinandankhilari9729
    @abhinandankhilari9729 2 ปีที่แล้ว +33

    One question - How to deploy this setup (frontend + backend) on hosting platforms like Netlify, Heroic, etc. for a working demo? Am I missing anything?

    • @CptUhudini
      @CptUhudini 6 หลายเดือนก่อน +1

      I would also love to know that

    • @zmarc-
      @zmarc- หลายเดือนก่อน

      you deploy them seperately. effectively two different sites

    • @dannny6019
      @dannny6019 25 วันที่ผ่านมา

      @@zmarc-I just figured this out. I was deploying the whole thing on netlify and expecting it to work but I just had to load the backend and frontend seperatly.

  • @jameshansen801
    @jameshansen801 2 ปีที่แล้ว +6

    I've been searching for a clear tutorial like this for weeks, thank you so much! The CORS issue has been driving me crazy. I enjoy the sound of your voice, as it makes it easier to concentrate, and I loved the way you explained everything. Again, thank you! :)

    • @lucasdesouza3658
      @lucasdesouza3658 2 ปีที่แล้ว +1

      Keep in mind that for production you should probably specify the origins the allow through cors. In her example she opens it up to any source which is also a small vulnerability. You can also serve the react app from the backend and leave cors blocked. That way only your front end can call you apis and not a clone site.

    • @jameshansen801
      @jameshansen801 2 ปีที่แล้ว

      @@lucasdesouza3658 Thank you so much! I just stumbled across that concept yesterday! This whole CORS thing has been so confusing. If you know of any kind of developer's security building checklist resources, it would be very much appreciated :)

  • @some_dude_on_the_internet
    @some_dude_on_the_internet 2 ปีที่แล้ว +4

    Nice to see steps to this setup. NextJS supplies "backend"/api routes outta the box w/o the need to rig it up yourself which is kinda nice.

    • @Meuhandle
      @Meuhandle 2 ปีที่แล้ว +1

      Yeah, actually a huge point for nextjs for this use case.

  • @hustle4837
    @hustle4837 2 ปีที่แล้ว +10

    I've a question. Someone can still inspect and see request URL (back-end endpoint). Even though API calling process happens on the backend, any one can use that endpoint to make request and get the response back. Yeah, they will not able to get API key, But they can make requests using our backend endpoint. Isn't it? How to solve that?

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +20

      Great question! And you are right, this can still happen. For this you need a few extra steps including request limiting and auth- this video is just how to hide your api key. :) I can make a video on this if you would like

    • @RobertThomasrob_thomasa10
      @RobertThomasrob_thomasa10 2 ปีที่แล้ว +4

      @@aniakubow Yes please!!!

    • @owenwexler7214
      @owenwexler7214 2 ปีที่แล้ว +2

      If you’re using NextJS you can use NextJS’ built-in API routes as a proxy to call your actual backend from and hide your backend’s URL and credentials in server-side environment variables (NOT prefixed with NEXT_PUBLIC_ in other words). Or if you are only getting info from an external API just use Next’s API routes, which are same-origin by default and can only be accessed by your frontend. This is actually a very good use case for NextJS as a framework.

    • @homy3484
      @homy3484 2 ปีที่แล้ว

      @@aniakubow Yes please, that where so awesome!

  • @jeremy_s
    @jeremy_s 2 ปีที่แล้ว +3

    Ideally you wouldn't even store any sensitive keys in your repo, especially in a commercial codebase with several/many engineers working on it. Depending on what infrastructure you use to host your backend, a better solution would be to store any secret values securely (not in plain text) and pass these values through at runtime.
    For example if you were using serverless functions with Azure, you could store your secrets in Azure Key Vault and retrieve what's needed when the function is executed (same concept for other cloud providers). This way your secrets are encrypted and secured properly while not exposed within your repo, on your server or to any team members who don't need to view these values.

  • @JamesQQuick
    @JamesQQuick 2 ปีที่แล้ว +4

    Love it!! Great work Ania :)

  • @frenchcoder-developpementw2429
    @frenchcoder-developpementw2429 2 ปีที่แล้ว

    You can also paste it in your package.json to hide your source code from the Chrome Dev Tools : "scripts": { "build": "GENERATE_SOURCEMAP=false react-scripts build" }

  • @victorekea
    @victorekea หลายเดือนก่อน

    This video should have a million likes! Thanks Ania.

    • @aniakubow
      @aniakubow  หลายเดือนก่อน

      😻

  • @elmatito5456
    @elmatito5456 2 ปีที่แล้ว +3

    amazing, thank you so much. Im a little bit lost though on hoy to deploy this, since the backend needs to be in another location

  • @rfgonzalezweb
    @rfgonzalezweb 9 หลายเดือนก่อน +1

    awesome content!! question: can I use this technique on the development of a chrome extension too? if not, what do you recommend? thank you

  • @junovue
    @junovue ปีที่แล้ว +1

    so my main issue is that i want to deploy this to github pages and use fire base for authentification. if we store this inside of .env variables, don't we then have to push the .env file to github? and how is that secure? is storing it in the back end really allowing web users to not be able to read those variables?

  • @Zzaa01
    @Zzaa01 2 ปีที่แล้ว

    I was looking for another video of yours and so happen to stumble upon this one and was like maybe I'll watch for a second. But I'm so glad I stumbled on this today! I will finish bootcamp next week and start a real job in a few weeks yet none of the instructors mentioned anything about how you can find the API key in the inspector tool! LOL Glad I know now!

  • @the_bestsoccer
    @the_bestsoccer 6 หลายเดือนก่อน

    This is the best explanation so far, even tough i use VueJS, but the code so far is still the same and can be used in VueJS. Thank you so much, keep going like this, okay?! 💪😎

  • @TheRemiRODRIGUES
    @TheRemiRODRIGUES 2 ปีที่แล้ว +3

    Thank you Ania !
    But it can't be only deploy on github pages, netlify, ... and other client side host, isn' t it ?
    With this solution the code should be deploy on Heroku, AWS, or other server side host, isn't it ?

  • @neoswann2143
    @neoswann2143 7 หลายเดือนก่อน +1

    So if I had to deploy the app, is the backend automatically deployed with production build?
    or does it have deployed separately?
    If so can you demonstrate how to properly deploy your frontend and backend to correspond properly.

  • @twilkpsu
    @twilkpsu 2 ปีที่แล้ว +1

    Have not watched this one yet, but Ania is solid and a master thumbnail marketer! 😉. Bravo!

  • @radupopescu2370
    @radupopescu2370 2 ปีที่แล้ว +35

    Never use front-end for sensitive data calls, always let the back-end handle those in a secure way. So learn some back-end and all will be good in your apps.

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +10

      Yes I agree :) hopefully this video helped in that

    • @radupopescu2370
      @radupopescu2370 2 ปีที่แล้ว +2

      I'm sure it did.All your videos are great and you explain in a way that's easy to understand.Thank you for the effort!

    • @FilipposSdralias
      @FilipposSdralias 2 ปีที่แล้ว

      @@aniakubow this video helped a lot!!!

  • @alexvel4414
    @alexvel4414 2 ปีที่แล้ว +5

    Thanks for the video, but i still don't get it. The api key maybe secure now but... What is stopping someone from making requests directly to your backend and using up all your quota for free. He does not even need an api key now, just the url of your backend. What can we do for this?

    • @amolsingh5882
      @amolsingh5882 2 ปีที่แล้ว +2

      Cors will stop those requests I believe

    • @alexvel4414
      @alexvel4414 2 ปีที่แล้ว +2

      @@amolsingh5882 why stop the others and not your own frontend then? Did the video include some way to whitelist only your own app? If i understood correctly it even included a cors plugin in the backend to allow such requests.

    • @TheRvh70
      @TheRvh70 2 ปีที่แล้ว

      @@amolsingh5882 Cors is only enforced by the browser. It doesn't stop people calling the backend directly via curl or postman for example

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +1

      There are a few more steps you would need to do for this. This video is just about making sure people don't steal your API key. :)

    •  2 ปีที่แล้ว

      @@amolsingh5882 No, cors won't stop. Just set origin in Postman and done.

  • @novusnota42
    @novusnota42 2 ปีที่แล้ว +1

    Plot twist: Ania just woke up after a nightmare about having lost all her keys and immediately proceeded to record a video, big respect.

  • @arulmuruganK94
    @arulmuruganK94 2 ปีที่แล้ว

    Thank you kaleeshi, you saved my kingdom. I was repeatedly asked about this in my interviews.

  • @rishavrungta
    @rishavrungta 2 ปีที่แล้ว +1

    Whats stopping someone to use this endpoint and get the value at my expense?

  • @BeeAttack
    @BeeAttack 2 ปีที่แล้ว +2

    Does this mean intruder can call back end api without any key and back end api will automatically put the key ? so how secure? or I misunderstood.

  • @IamSH1VA
    @IamSH1VA 2 ปีที่แล้ว +7

    *This tutorial is really really useful and Important.*
    I was using env for react unsafe way , thanks to you now I know safe way.
    Again thanks 🙏😊

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +1

      I’m so happy you found this useful! Yes , I really wanted to show why it’s not safe to store API keys on the frontend too :) thanks so much for your kind words and support

  • @CharlieAligaen
    @CharlieAligaen 8 หลายเดือนก่อน

    Great Tutorial! Need to change your smoke alarm battery, though. 😁 10:19

  • @ingeniodigital7414
    @ingeniodigital7414 2 ปีที่แล้ว

    Awesome quality content. The sound and speed of your voice makes easier to follow and understand every concept.

  • @SamzehGFX
    @SamzehGFX 2 ปีที่แล้ว

    Awesome video, really great showing the benefit of feeding your api requests through a nodejs backend!

  • @vadimbondaruk8133
    @vadimbondaruk8133 ปีที่แล้ว

    It would be cool if you will provide tutorial how to deploy this app

  • @acomathes
    @acomathes 2 ปีที่แล้ว +1

    Thank you for the video! One thing I don't understand though. Will it still work when we build the frontend project statically, deploy it on a VPS and also get the backend's index.js running on that VPS? When a user opens our published static frontend, will the localhost then will be relative to the user?

  • @IAmOxidised7525
    @IAmOxidised7525 2 ปีที่แล้ว +2

    use a reverse proxy to store API keys , and make actual API calls from there,
    Request structure:
    Client -----> Reverse Proxy --------> Backend
    React ------> API keys stored here -----> Backend that use API key
    Reverse proxy can also be used to remove some headers like X-powered-by , rate limiting , as a load balancer etc.

    • @OliverK-w8m
      @OliverK-w8m 2 ปีที่แล้ว +1

      Hey. Can I have your discord? You seem to understand these topics. Im looking for some assistance...

    • @OliverK-w8m
      @OliverK-w8m 2 ปีที่แล้ว

      So what is your discord?

    • @sephirot7581
      @sephirot7581 2 ปีที่แล้ว

      Reverse Proxy to store api keys? That doesnt really make sense. You would store the key in the backend itselft or any store management, etc. You can use a revese proxy to centralize your authentification and authorization concept.

    • @kuroexmachina
      @kuroexmachina 2 ปีที่แล้ว

      bruh just use kubernetes or AWS secrets lol

    • @sephirot7581
      @sephirot7581 2 ปีที่แล้ว +1

      @@kuroexmachina lol, this has nothing todo with the problem?

  • @themsaid
    @themsaid 2 ปีที่แล้ว +3

    Great Video!
    Some call this pattern "Backend for Frontend" or BFF. It can be used to store authentication tokens in the backend instead of the browser cookies or local storage.

  • @trtlphnx
    @trtlphnx 2 ปีที่แล้ว +3

    Damn I Love Your Incredible Tips and Strategies ~
    Love You Ania, And ALL You Do For Us ~

  • @galibhossan15
    @galibhossan15 11 หลายเดือนก่อน

    can you make another tutorial with this project for deploy it with firbase and github? or any documentation for it?

  • @cyberianoid
    @cyberianoid 2 ปีที่แล้ว

    *Very important info for my study projects! Thanks, Ania* 😀
    On the Cloud provider that I use for deploy my applications, there is a service called "Lockbox" which is used to store secrets inside an encrypted cloud storage.. But I have not used it yet. Thanks to you, I understand now why it is needed :)

  • @williamkmp9998
    @williamkmp9998 2 ปีที่แล้ว +3

    Hi thank you for this video it helped me A LOT, I'm just beginning to understand backend and API and I am wondering aren't malicious people can still make request and use the api key by inspecting the frontend code, find the url to the backend and then do many request to the server? I'm having trouble trying to work this out thank you. Sorry for my broken english I'm not too fluent.

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +3

      Wonderful question - there are other steps you can do to increase security like request limiting, making sure the API is only used with your domain - I can make a video about this too / not just hiding your API key :)

    • @williamkmp9998
      @williamkmp9998 2 ปีที่แล้ว

      thank you so much this is so helpful.

  • @amolsingh5882
    @amolsingh5882 2 ปีที่แล้ว +1

    Great video as always.
    I have 1 doubt - how is the deployment done. I mean how is the code packaged for, let's say a Docker image ?

  • @dr.downvote
    @dr.downvote 2 ปีที่แล้ว +1

    Absolutely beautiful. The video is good too.

  • @brandon14125
    @brandon14125 2 ปีที่แล้ว +8

    This is why I wish web development would move away from putting so much application logic into a frontend app. Anything on the frontend is visible by the user. Any validation in your front end app just be replicated in your backend logic if you want it to remain secure.
    I miss minimal frontend apps.

    • @PhilipAlexanderHassialis
      @PhilipAlexanderHassialis 2 ปีที่แล้ว

      And this is why SSR is getting traction: you get the best of both worlds.

    • @prezire
      @prezire 2 ปีที่แล้ว

      @@PhilipAlexanderHassialis are SSR's really needed? IMHO there is traditional MVC, which already looks good. what's your opinion about MVC vs SSR?

  • @ping9646
    @ping9646 2 ปีที่แล้ว

    Thanks for a very very good step by step video for such an important topic. I will come back to your channel for more insightful react tips 👍

  • @AdrianClaudiuDima
    @AdrianClaudiuDima 2 ปีที่แล้ว +1

    Even if you expose your API key, you can configure the sever only to allow calls from your domain.

    • @shaunlobsinger
      @shaunlobsinger 2 ปีที่แล้ว

      I’d be careful as some services may not offer that. If you’ve ever exposed your API key assume it is not safe anymore and reissue it from whatever service your using.

  • @FuzzyDunlopification
    @FuzzyDunlopification 11 หลายเดือนก่อน

    My understanding is that React will bundle your .env file during the build process regardless so either way the key is exposed?

  • @priopambudi9533
    @priopambudi9533 2 ปีที่แล้ว

    Thank you Ania! I'm just confused to handle the key in the frontend, and you're very helpful!

  • @martinmiguez6153
    @martinmiguez6153 2 ปีที่แล้ว

    Great, thanks for sharing what you know! I just asked myself, when the build is made to production, it also does it with this backend file? Thank you

  • @xfire4267
    @xfire4267 2 ปีที่แล้ว +1

    Hello Internet Ania. 🙋‍♀️
    Thank you for this video. I have learned a lot.

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +1

      That’s so good to hear 😄

  • @whatnow1194
    @whatnow1194 2 ปีที่แล้ว +1

    this was really helpful
    definitely will be using in my projects

  • @hcivelek
    @hcivelek 2 ปีที่แล้ว +1

    Thank you for this clear video. Very helpful. I wonder that after creating a small backend here, how do we prevent outsider usage. We hid the key but open the door completely. If they use our backend, instead of stealing our key, we may see the big fat bill anyway.

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +8

      That is a great question! There are other steps to do this that I can make a video on, including request limiting and making sure the API is used only on your domain etc. Watch this space :)

    • @marcelo123456789lope
      @marcelo123456789lope 2 ปีที่แล้ว

      @@aniakubow are you talking about CORS? How to apply this domain restriction???

    • @stvfun810
      @stvfun810 2 ปีที่แล้ว

      The domain restriction will only work for web, how do we ensure that the API can be called by our mobile app only

    • @homy3484
      @homy3484 2 ปีที่แล้ว

      @@aniakubow First of all, thank you so much for this great tutorial. That would be so nice if you could also make a vdeio. I have this exact problem but can't get it solved with acces cotnrol, ip white list or cors. I do not know how to do it, because always another IP of the user accesses.... It would be super sweet of you to make a tutorial on this. Many many thanks! :)

  • @aleihnad
    @aleihnad 2 ปีที่แล้ว

    With next js because the server side is more easy i think, but your video is so helpful. Regards from chile (sorry for my english)

  • @losVamonos
    @losVamonos 8 หลายเดือนก่อน

    Hi Ania, do you have an updated way of creating a proxy server to keep API keys secure?

  • @FilipposSdralias
    @FilipposSdralias 2 ปีที่แล้ว +1

    Thanks Ania! It is a very helpful tutorial! You saved my day!
    I was wondering how we can move the index.js file under an api forlder so we can deploy as serverless function (for use on vercel, netfly etc)

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +1

      Thanks so much! You can move the file to an api folder - however, you might have to rewrite the code :) I have a tutorial on writing your own Netflix serverless function if you want to check that out 😊

    • @FilipposSdralias
      @FilipposSdralias 2 ปีที่แล้ว

      @@aniakubow Thanks! I did! It is pretty understandable from beginners' perspective! Thans for sharing! About the last question, I did move it and it work but I need to make some code adjustments as you mentioned! Thanks again!

  • @stoyankoychev102
    @stoyankoychev102 2 ปีที่แล้ว

    Amazing, but how you deploy it?

  • @sevsol88
    @sevsol88 2 ปีที่แล้ว +1

    Is the lack of semicolons on your code a stylistic thing or is it recommended or something??

  • @BALAJIM-rt5fy
    @BALAJIM-rt5fy ปีที่แล้ว

    its working perfectly in local but i need to depolye in iis so i need to build the application on that case what should i do with index.js and so fetching url of backend nodeserver url ?

  • @emanuelal.6490
    @emanuelal.6490 2 ปีที่แล้ว

    Great tutorial! Greetings from Argentina 👋

  • @AbhishekSharma-rs9ub
    @AbhishekSharma-rs9ub 2 ปีที่แล้ว +1

    Love form india ❤️
    Amazing tutorials 👌👌
    this is helpful for me 🙏🏻🙏🏻

    • @AbhishekSharma-rs9ub
      @AbhishekSharma-rs9ub 2 ปีที่แล้ว

      @Code with Ania kubó ❤️❤️

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว

      @@AbhishekSharma-rs9ub Careful, that is a bot impersonating me - I have now blocked them and reported :)

  • @bgill7475
    @bgill7475 2 ปีที่แล้ว

    Thank you very much.
    Your videos are so good and informative :)

  • @zakhariihusar6975
    @zakhariihusar6975 2 ปีที่แล้ว

    Nice topic 👍. Often was wondering about safety of API keys

  • @netsaosa4973
    @netsaosa4973 ปีที่แล้ว

    Thanks, I got confused on the whole parameter thing. My API call doesn't use queries so I had to pass my front-end parameter as the useState array and declare it in expressjs as const stateThing = req.query.stateThing

  • @noorsh
    @noorsh 2 ปีที่แล้ว +1

    Hello Ania. Thanks a lot for your time and this tutorial! I have a question about the deployment. How to deploy the backend without it being revealed? Thanks again

    • @LeedleLeedle2212
      @LeedleLeedle2212 2 ปีที่แล้ว

      Create environment variables with the service you’re using to deploy your code. I’ve done this with Heroku, I’m sure it is possible with other services too.

    • @priopambudi9533
      @priopambudi9533 2 ปีที่แล้ว

      @@LeedleLeedle2212 Do you have any suggestion video tutorial for this?

    • @LeedleLeedle2212
      @LeedleLeedle2212 2 ปีที่แล้ว

      @@priopambudi9533 the 30:00 minute mark of this video can help.
      th-cam.com/video/ZGymN8aFsv4/w-d-xo.html

    • @priopambudi9533
      @priopambudi9533 2 ปีที่แล้ว +1

      @@LeedleLeedle2212 Thats amazing. Thank you so much. You're the best!

  • @rohan_webdev
    @rohan_webdev 2 ปีที่แล้ว

    Thanks Ania,👍 it was super helpful.

  • @marianareissilveira
    @marianareissilveira 2 ปีที่แล้ว

    Great video Ania!
    I was wondering, how can I use this method to hide my keys in React Native? Would that be the same thing?
    Thanks

  • @peoplecaringsharing
    @peoplecaringsharing 2 ปีที่แล้ว

    Superb helpful info sharing as superb beauty you are ! Thanks a lot.👍👍👍😊

  • @andreifish6818
    @andreifish6818 2 ปีที่แล้ว

    With this approach you are creating a server, without any auth, which leads to: consumer, who knows the url of the service, may use this API to request data, which you are encapsulating. (Which apparently doesn't really fix the issue, but adding you a bit more cost to host this server. Plus you are making it easier).
    It can help only if you are hosting both client and server on the same isolated instance, but this may look like an overhead.
    You may create an interceptors on the instance, which will wrap your specific requests with data you need.
    For e.g. AWS Cloudfront has that functionality OOTB, but if you are creating an instance without any cloud services - you can do that even by system utils.
    Maybe I've missed something, anyway, thanks for highlighting this problem 👍

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว +3

      This video is just for keeping the API key safe as per the title :) - if you would like a video about auth or request limiting etc I can make a video on that :) I find just tackling one frequently googled question per video is a good format to have, but maybe I am wrong - who knows

  • @tamilprogrammer
    @tamilprogrammer ปีที่แล้ว

    Your thumbnail font is awesome... What font are you using?

  • @natnaelamanuel
    @natnaelamanuel 2 ปีที่แล้ว +1

    Would have loved an angular version of this too. Would it be the same?

    • @tronixmobile
      @tronixmobile 2 ปีที่แล้ว +5

      It's pretty easy. Never insert an API key in your frontend Javascript! You can use a backend proxy or an API gateway.

    • @natnaelamanuel
      @natnaelamanuel 2 ปีที่แล้ว

      @@tronixmobile thanks for the info 👍 🙏 😀

  • @jianiliu6701
    @jianiliu6701 2 ปีที่แล้ว

    Followed you along, but keep getting this error, TypeError: Cannot read property '5. Exchange Rate' of undefined...

  • @mofe620
    @mofe620 ปีที่แล้ว +1

    Thanks a lot for this

  • @ryanborgy
    @ryanborgy ปีที่แล้ว

    How does this help? I mean what prevents someone from just calling that backend endpoint and using the token? Is there any authorization on the backend API?

  • @zeywox3043
    @zeywox3043 ปีที่แล้ว

    if you receive the environment variable through http request, doesn't that appear on the network tab ? !! can you share the source code ?

  • @frenchcoder-developpementw2429
    @frenchcoder-developpementw2429 2 ปีที่แล้ว +1

    The problem with this technique is that if the attacker calls your backend API, they can simply retrieve the data returned by your backend!

    • @talljohnpaul
      @talljohnpaul ปีที่แล้ว

      I was thinking the same. Also what happens when you host your repo to a place like Netlify, it would build the repo then would build a Back end from that index.js? Thats pretty cool.

    • @Mark-ic4hl
      @Mark-ic4hl ปีที่แล้ว

      Cors

  • @LaFCueva
    @LaFCueva 2 ปีที่แล้ว

    Thank you so much!!!! This was super useful!

  • @fitnessmind8638
    @fitnessmind8638 ปีที่แล้ว

    plz any one help to explain which extension give automatic snipets in this tutorial

  • @dc366
    @dc366 ปีที่แล้ว

    Where is the link for Part 1?

  • @yousoffatomi
    @yousoffatomi 2 ปีที่แล้ว

    we connot hide api key , but user can see api key in network tab

  • @lavishly
    @lavishly 2 ปีที่แล้ว

    Can you mention how to do it in Cordova and Ionic too when you release?

  • @rapustin
    @rapustin 2 ปีที่แล้ว

    but can see the data on the networks options on navigator. How solution this fail?.

  • @eduardoranierosilva
    @eduardoranierosilva 2 ปีที่แล้ว

    once again, thank you so much!

  • @kenan3121
    @kenan3121 2 ปีที่แล้ว +1

    we can actually run the server side and the client side concurrently under one terminal .
    $ npm install concurrently -g
    -go to server/package.json add three scripts:
    "server" : "nodemon app.js",
    "client" : "npm start --prefix ../client",
    "con" : "concurrently \"npm run server \" \" npm run client\" "
    now if we run :
    $npm start con
    both the server and the client will start under one terminal
    please note that :
    (nodemon) in server script can be replaced with (node).
    the folder structure is
    main_DIR
    |
    \client (REACT project)
    |
    \server (Node js project)
    please make sure that you setup a proxy in the client\package.json that refers to the express server.
    example:
    if the express server is running on PORT 5000.
    the proxy in client\package.json should look like this :
    "proxy":"localhost:5000"
    i hope it helps someone.
    peace

  • @thiagoleobons390
    @thiagoleobons390 ปีที่แล้ว

    Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    just cloned, npm i and ran frontend :(

  • @rowheadrex
    @rowheadrex ปีที่แล้ว +1

    @ 14:09 you were prompted between Arabic / English translation.
    are you learning Arabic these days? I wouldn't be surprised if you were :)
    BTW great value lessons you offer indeed

  • @Deadragonbone
    @Deadragonbone 2 ปีที่แล้ว +1

    I want to thank you. You make programming popular amount women 👏

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว

      💚💚💚

  • @Tech_Wes_
    @Tech_Wes_ 2 หลายเดือนก่อน

    @10:23 where you configure the configuration for your run commands, how do i configure that in vscode? I've tried researching, but I can't figure out how to get the edit configuration screen to pop up like yours and edit the run command? Thank you for the tutorial!

    • @aniakubow
      @aniakubow  2 หลายเดือนก่อน +1

      Hello! I am using Webstorm for this so it’s different than vscode :). But you can just edit the npm run command in the package.json file also, and run the command in the terminal. Does that make sense ?

    • @Tech_Wes_
      @Tech_Wes_ 2 หลายเดือนก่อน

      @@aniakubow Ahh thank you for the quick response, i really appreciate it. Yeah, I ran npm start:front end and it seemed to work. Took me a bit of configuring, but my imdb api is looking real nice. Thanks again!

  • @zombaju
    @zombaju 2 ปีที่แล้ว

    Hi, I use Firebase for work and unfortunately those values that I "hide" in .env are visible in some operations in the browser console. I don't know if this is normal in Firebase?

  • @zubairlohar3557
    @zubairlohar3557 2 ปีที่แล้ว

    Doing awesome job Queen 👑

  • @jgibson8092
    @jgibson8092 ปีที่แล้ว

    Just found this video and ive already uploaded a movie app to my GitHub im new to web dev. Should i remove the app . She said someone can still find your API key in your github history how do i fix that can someone help me .

  • @salehaleit1501
    @salehaleit1501 ปีที่แล้ว

    What about building a mobile app that connects to an API, CORS will not suffice then.
    This technique is also highly vulnerable to XSS attacks.

  • @dysper971
    @dysper971 2 ปีที่แล้ว +1

    Yes !!! 🤙🏽🤙🏽 i'll be there !

  • @muhammadazfaraslam8610
    @muhammadazfaraslam8610 2 ปีที่แล้ว

    What about the redux saga? if we're using middleware like a saga, will it still not be saved to use env?

  • @softtech3172
    @softtech3172 2 ปีที่แล้ว

    thank you so much

  • @errinwright
    @errinwright 2 ปีที่แล้ว

    Thank you you are amazing!!

  • @sahartal9503
    @sahartal9503 2 ปีที่แล้ว

    Good One, thanks!

  • @antonjalalipour4499
    @antonjalalipour4499 2 ปีที่แล้ว

    Hi Ania. Do you know how we can display the currency exchange rate with only 2 decimal points please? Right now it shows it with 6 decimal points. Thanks!

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว

      You can use the .toFixed() JavaScript method and pass through the number 2 :) so .toFixed(2) . I think we do it later in the tutorial ?

  • @ajayraja6636
    @ajayraja6636 2 ปีที่แล้ว +1

    May I know which database you're going to use?
    Is Postman needed?
    In my region, Your video premieres
    in Mid night 😭😭😭

    • @ajayraja6636
      @ajayraja6636 2 ปีที่แล้ว

      @Code with Ania kubó I think Discord server would be better than Whatsapp

    • @aniakubow
      @aniakubow  2 ปีที่แล้ว

      @@ajayraja6636 Careful, that is a bot impersonating me - I have now blocked them and reported :)

  • @rapustin
    @rapustin 2 ปีที่แล้ว

    If you dont have possibility of execute backend?

  • @saeidghorbani4388
    @saeidghorbani4388 ปีที่แล้ว

    thank you

  •  2 ปีที่แล้ว +1

    I'm sorry but what's the difference of "hiding" api key compared to exposing whole API without any api key or auth? This tutorial without next steps have no sense for me.

  • @huhu77700
    @huhu77700 2 ปีที่แล้ว +2

    Or you could use Next to do that easily. Most API keys meant to be used in frontend requests are also domain-limited.