React Security - Add an API Proxy

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 พ.ย. 2024

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

  • @user-fl5xn8dw4k
    @user-fl5xn8dw4k 3 ปีที่แล้ว

    Thanks! WOW, even works with webpack, all you gotta do is specify the proxy in the devServer and you're all good! Thanks once again!

    • @altamasahmed840
      @altamasahmed840 3 ปีที่แล้ว

      can you please explain it more , Im stuck, please help :)

  • @tarsier419
    @tarsier419 3 ปีที่แล้ว +8

    If you could do this WITHOUT create-react-app you would be my hero. The "proxy" doesn't work.

    • @abhishek.rathore
      @abhishek.rathore 3 ปีที่แล้ว +2

      Same. Have you found a work around yet?

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

    Do you have experiance with full stack development and Cloud Architecture?

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

    how to give multiple proxy

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

    what to do , if we want to host it on other hosting, how to prevent CORS

  • @aboutdotnet
    @aboutdotnet 3 ปีที่แล้ว

    This video is a life saver. Brilliant. Thank you!!

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

      dont talk lier lier

  • @mdridoy-ef2pw
    @mdridoy-ef2pw 3 ปีที่แล้ว +2

    It worked at first...But for some reason the proxy is not working anymore...
    how to fix this?

    • @abhishek.rathore
      @abhishek.rathore 3 ปีที่แล้ว

      Same. Did you find a solution?

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

      It only works while developing the app. Not after deployment

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

    That's a great solution for the dev environment, but how about when we deploy will we need to change from localhost:3001 to the cloud server URL? Will the proxy work in this case? 😊

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

      same domain is the solution in terms of actual production mode

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

    This doesn’t expose the env on client side?🤔

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

    but why do we need proxy to have cookies work properly? any external api will simply store the cookies in the client's browser, without the use of the proxy. that should itself work just fine...am i missing something?

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

      Third party cookies can be set, yes, but the cookies themselves will only be sent back to the domains from which they came. So if we run the frontend on localhost:3000 and the backend on 3001, the cookies that get set on 3000 won't be included in any requests that go to the backend. Proxying the backend such that they both run on the same domain is the fix for that :)

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

    My project didn't have a file .env.local so I created it, but proxy not helps. Client run on different port 3002 and express-server on 3001

    • @abhishek.rathore
      @abhishek.rathore 3 ปีที่แล้ว

      Same. Did you find a solution to this?

  • @web8351
    @web8351 3 ปีที่แล้ว

    thanks a lot. i finally got cros problem solved, I used the module proxy middleware.

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

    Great concise video! A quick question, how would you serve this in a server for example I have an a react app that has pages as components as well as a server js file for api calls like your video and a proxy setting like yours but in iis how do I serve both my index file and server js file calls in my web config file? Because you wouldn’t use proxy in production right? Any help would be amazing

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

      I don't have any experience with IIS so I don't know myself, but I did ask ChatGPT and got something that looks good! Have a look here and let me know if it works: gist.github.com/chenkie/3b9214ea77de0bca2a05e5e335750218

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

      npm run build in frontend folder then copy frontend folder to backend folder root. Need to add a line a code in server.js or app.js app.use(express.static(path.join(__dirname, "../frontend/build")));
      app.get("*", (req, res) => {
      res.sendFile(path.resolve(__dirname, "./frontend/build/index.html"));
      });. Run server using npm start.

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

    did not work for me pls help

  • @victorpotes
    @victorpotes 4 ปีที่แล้ว

    Hey that's great, what about if I need to call more than one api with different domains, this solution wouldn't work. I'm facing that problem right now, I'm using http-proxy-middleware, but the browser blocks the cookies and sessions. What could you advise me? Thanks by the way.

    • @holodeck_run
      @holodeck_run  4 ปีที่แล้ว

      you might be looking for more of an API gateway setup in this case. th-cam.com/video/vHQqQBYJtLI/w-d-xo.html

    • @victorpotes
      @victorpotes 4 ปีที่แล้ว

      @@holodeck_run Thanks!

  • @LuisRamirez-dx4id
    @LuisRamirez-dx4id 3 ปีที่แล้ว

    Hello good afternoon! Adding the "proxy" in package.json is when we are in dev stage, how can we keep the functionality when we deploy?

    • @holodeck_run
      @holodeck_run  3 ปีที่แล้ว

      there are several ways to do it when deploying :) you might look into Caddy server. that's what I'm using now: caddyserver.com/

    • @rafliramadhan1392
      @rafliramadhan1392 3 ปีที่แล้ว

      same issue, can u give an example?

    • @mahmoudalqiaty3366
      @mahmoudalqiaty3366 3 ปีที่แล้ว

      @@rafliramadhan1392 Hello dear, did you find a solution to this problem? I'm facing the same problem now, can you help me??

  • @creativetech8471
    @creativetech8471 3 ปีที่แล้ว

    Never ever should we use proxy like this, Bad practice

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

    I have a question please When I use a proxy server and I follow people on Instagram, the follow-up is not done, for example, I have 5 followers on Instagram and I request to follow 100 people, that account is not done, they are still following 5 people, I just want to know how this happens, can the effect of the reverse proxy or forward proxy or requests sent can be redirected please help me