React Proxy | Easiest Fix to CORS Errors

Поділитися
Вставка
  • Опубліковано 3 жов 2024

КОМЕНТАРІ • 156

  • @toxy6355
    @toxy6355 Рік тому +50

    sir, 4 hour,its 8:25AM, i was trying to solve this from around 3:30AM. you cant imagine how happy i am right now to find those 4 line of code in ur first 10 sec of video...... i love you man even turned on bell icon cz u saved my project, i was about to delete it

  • @niranjans.r1930
    @niranjans.r1930 5 місяців тому +4

    Unlike every other youtubers who says bunch of nonsense and non related things before giving the actual information for which we came for, You gave the most important information in the first 10 seconds and proceeded to explain it later. You have our respect.

  • @knecks7374
    @knecks7374 Рік тому +2

    bro after 2 and a half hours of struggling around , i had lost my hope. and the i decided to watch this full video as my last tether to sanity. and that stupid failed to fetch error is finally gone. thank you dude. god bless you.

  • @krzysztofkrawczynski9404
    @krzysztofkrawczynski9404 Місяць тому

    14 seconds of video pointed me into right direction. Thank you!
    Those CORS configurations are pesky . Local frontend, local backend, GitHub, remote frontend, remote backend, DEV, TEST, PROD - all permutations turn development into a quagmire. Thank you for the explanation.

  • @Asad_The_Second
    @Asad_The_Second Місяць тому

    If only all tutorials were this thorough.
    Thanks for the video

  • @krishangsharma2185
    @krishangsharma2185 8 місяців тому +1

    I was so stressed out about the whole CORS issue, and this, this is just gold. Straight and to the point explanation! Really appreciate the work!!!

  • @---qp8bs
    @---qp8bs Рік тому +7

    This entire list of react focussed videos is great, It is obvious you spent a huge amount of energy on taking us along on the learning curve- just compare the first couple of videos to this, it's a great expansion building on the previous knowledge!
    This video really blew me away with the quick deployment on railway, that's awesome.
    Also loving the quick snippet at the start showing the main point!

  • @charlesbrz
    @charlesbrz Місяць тому

    I am a bit clueless. But this guy pushed me in the right direction in a way I could understand. Your work is greatly appreciated

  • @number5322
    @number5322 Рік тому +2

    I spent a whole night trying to circumvent those cors issues. Thank you very much. Now I'll go get some sleep

  • @mrmaahi4945
    @mrmaahi4945 5 місяців тому

    I never thought that I can solve my intital (proxy setup) and final (deployment) problems by just watching one video.
    Spent all day trying different way to deploy my project but lost functionality after deployment. Finally deployed using the process in the video and everything is working sooo fine and it's soo easy. I can't thank you more, u really saved my day here and explanation is on point that made me think like, "what the hell, I understand everything this guy saying" . THANK YOU SO MUCH

  • @oyivosamuel7185
    @oyivosamuel7185 Рік тому +1

    I dont really know u and this is my first time of watching ur video but ur video just saved me after 4 days of trying to connect my vite React project with my node js without using cors.......U are a life saver for that am subscribing......thanks again

  • @tiktaktictac
    @tiktaktictac Рік тому +6

    This clears up a lot for me man. This is the first time I try to make a fullstack app and all these deployment issues are confusing af. Thumbs up for you 👍

  • @spab87
    @spab87 22 дні тому

    THANKS A LOT!!! (I've been trying to fix this bug for couple of hours, installed nginx, like a billion of cors expansions and set everything on my Flask server... thanks for explaining it all

  • @amouzande9102
    @amouzande9102 6 місяців тому

    Thank you so much for this tutorial, I've searched lots of videos and site but none of them specified exactly how to solve it in vite. really appreciate it Sam

  • @ДмитрийБондарь-ж1у
    @ДмитрийБондарь-ж1у Місяць тому

    Thank you! Excellent explanation with real examples. It really helps me to fix my issue and understand the problem.

  • @siddhantsrivastav8591
    @siddhantsrivastav8591 Рік тому +4

    Really awesome video. Telling the solution at start and then it's upto the user to say. Love it man! Hope to see more youtubers be this thoughtful

  • @VisionRevealed
    @VisionRevealed 9 днів тому

    Hi, thank you sam for the videos, really amazing content, best practices, great explanation, good energy. I appreciate everything!
    Here are few tips if you are using the proxy on vite:
    - after setting up the proxy, make sure you have /api/example endpoints on your server, because if not, when you build your project the http requests will be send to /api/* endpoints and if they don't exist in your server, that will cause an error;

  • @juanguerrero0941
    @juanguerrero0941 Рік тому +1

    I needed a solution as fast as possible, I looked a lot of videos that didn't help me, but this one in the first 30 seconds gave me the answer, thank you

  • @ashharSartaj
    @ashharSartaj Рік тому +5

    Can't thank you enough brother. After almost 4 hours of frustration, got the appropriate solution. Also, CORS package wasn't fulfilling the purpose, as suggested by other channels.

  • @avalanche-arabic
    @avalanche-arabic 2 роки тому +2

    Thank you so much, after a week of search i got my issue fixed and finally the data renders on my frontend up! Keep up the great work! Thank again!

  • @stalinengoma7680
    @stalinengoma7680 Місяць тому

    Thank you for explaining this.
    I thought we have to use CORS in the backend and the Proxy in the frontend o mmake it work but your video just cleared my doubts

  • @4xsjb
    @4xsjb 5 місяців тому

    What a legend , i've been stuck with this for 3 days . it almost seemed impossible to solve then this video showed up when i was just scrolling 😄

  • @jaitjacob
    @jaitjacob 7 місяців тому

    you make videos of things I've wondered about at some point during my learning process, so good! this cors issue was something I fixed using an extension without really paying attentions to the whys and how's

  • @itchybakerzz5101
    @itchybakerzz5101 Рік тому

    I've been looking for a solution about the proxy in vite-react for days, then this video solved it within 20 seconds. Thanks a lot!

  • @CoFloCipher
    @CoFloCipher Рік тому +1

    Just wanted to say this helped me in a bind. Thank you!

  • @OgbonnaBlessed
    @OgbonnaBlessed 28 днів тому

    Thank you so much for making this video sir, it actually helped solve and clear the error I was encountering.
    Thank you so much sir.

  • @FaySaud-j3l
    @FaySaud-j3l 7 місяців тому

    Thank you so much , you can’t imagine how grateful I am for this clearly instructed solution,I’ve been stuck on this CORS issue for 3 days and went through a lot of solutions and videos but yours is what worked best for me 🙏 thank you again

  • @danielcinspace1
    @danielcinspace1 Рік тому

    The first video I have ever commented on. CORS was driving me nuts. Thank you!

  • @chrisdan81
    @chrisdan81 9 місяців тому

    thank you for this... I have been searching for this for 4 hours ...

  • @WohSaadgi
    @WohSaadgi 2 місяці тому

    Thank you very much Sir for this Important and deep understanding video

  • @linak1909
    @linak1909 5 місяців тому

    omg this is amazing XD immediately subscribed!

  • @jaisikadhiman9791
    @jaisikadhiman9791 4 місяці тому

    Thanku , after wasted of 2 hours i found the solution of this problem thanku😊

  • @explorelifewithleo
    @explorelifewithleo Рік тому

    This video clears all my doubts about proxy server. amazing content!!

  • @Hadrian-w9c
    @Hadrian-w9c 9 місяців тому

    Dude, this vid saved my butt.... spent ages trying to solve a proxy issue... Sub'd!

  • @SékouDayifourouKeïta
    @SékouDayifourouKeïta Місяць тому

    You're a master bro. Keep going ❤

  • @sagarchawla4926
    @sagarchawla4926 Рік тому

    Amazing dude, i was stuck for a whole day figuring out whats wrong.

  • @74LS_NE555
    @74LS_NE555 Рік тому

    thank you for getting to the point from the start [subbed]

  • @MatthewMcGuff
    @MatthewMcGuff Рік тому

    I really like this pattern for building full stack react and node applications. Thanks for the video.

  • @harshitprasad1064
    @harshitprasad1064 Рік тому

    God bless you man!!! Thank you very much for sharing what I was looking for in the first 10 seconds of the video instead of scattering it throughout the video... ❤

  • @ankush1228
    @ankush1228 Рік тому

    i literally spent 2 days on cors and hosting but you made it in 15 min thanks man🥺🥺🥺

  • @vlogs627
    @vlogs627 Рік тому

    Thanks. It saved my 4 hours of headache.

  • @rogut8
    @rogut8 2 роки тому +1

    Wow, that was fast mate. Thank you Sir :)

  • @vinodpatil7314
    @vinodpatil7314 6 місяців тому

    sir from past 2 days i spent all midnight just chatgping the proxy thing and today just at 0:13 i got the solution thank you so much

  • @akashddeepchitransh4537
    @akashddeepchitransh4537 4 місяці тому

    Incredible video learned a lot

  • @watcharaponhongthong7869
    @watcharaponhongthong7869 2 місяці тому

    Very clear! Thanks:)

  • @c1ach027
    @c1ach027 Рік тому

    Thanks you ^^,I find this pbm with my Java Spring api and Vuejs, after your tutorial it's work. Your the best ^^

  • @javiergarciafillol4454
    @javiergarciafillol4454 Рік тому

    Grath, a simply solution for the express & proxy develop

  • @aliyazdan6282
    @aliyazdan6282 7 місяців тому

    wow it was such a amazing video it got my lot of doubts cleared

  • @nikolaradulovic9145
    @nikolaradulovic9145 Рік тому

    Valuable content, thanks for sharing knowledge!

  • @jawadsaleem7495
    @jawadsaleem7495 Місяць тому

    You are a life saver vruhh...

  • @teminoah2960
    @teminoah2960 Рік тому

    thanks Mr Sam , this absolutely helpful .

  • @sambashivaraoboyina3191
    @sambashivaraoboyina3191 2 місяці тому

    Excellent explanation

  • @FunkyLPify
    @FunkyLPify Рік тому

    Thanks very much for the video! Got a bit confused why some other tutorials like uploading an image to S3 didn't work for me with the way you did it, but it was because of the missing proxy haha

  • @muhamadsarhad6566
    @muhamadsarhad6566 9 місяців тому

    just WOW! man this was amazing.

  • @abhishekvishal354
    @abhishekvishal354 Рік тому

    Thank u man so much ....
    This vid was a blessing

  • @peyy7645
    @peyy7645 2 місяці тому

    Sir, U saved my life 😭😭

  • @Geekoo
    @Geekoo 7 місяців тому

    Wow I can't ask more than this

  • @111ramico
    @111ramico 7 місяців тому

    Thank you
    it was delighted 🙂

  • @crypto1886
    @crypto1886 6 місяців тому

    Thank you, you have recived my sub and like

  • @triviachanel
    @triviachanel Рік тому

    Thanks man, you save my life.

  • @edwardespinoza1729
    @edwardespinoza1729 8 місяців тому

    Awesome video!

  • @AnsonBenny
    @AnsonBenny Рік тому

    Tnks bro its working very well, keep going👍

  • @mehrosenasir9974
    @mehrosenasir9974 Рік тому

    Thank you so much from Pakistan!!

  • @DeepakisDemigod
    @DeepakisDemigod Місяць тому +1

    God Bless You ❤❤❤

  • @mugilhustler5532
    @mugilhustler5532 19 днів тому

    U save my day

  • @maksymstarodubtsev6704
    @maksymstarodubtsev6704 3 місяці тому

    thanks, it helps a lot

  • @kishoreandra
    @kishoreandra 2 роки тому

    Waoh thanks for the video Sam 🙌 subscribed 😉

  • @user-fy2hp
    @user-fy2hp Рік тому

    Thanks that's a great helpful information

  • @toluwanimiala4729
    @toluwanimiala4729 5 місяців тому

    great vid 🤌

  • @thesoftwareengineersjourney

    Thanks I was able to fix a problem with this

  • @scey
    @scey 9 місяців тому

    thank you so much! perfect!

  • @StefanoMercadante
    @StefanoMercadante 4 місяці тому

    thank you thank you very much!!!!!

  • @zihuatanejo7741
    @zihuatanejo7741 2 роки тому

    Thanks a lot, great video :)

  • @mubashirwaheed474
    @mubashirwaheed474 Рік тому +3

    Thank you, Sam, for explaining that we have our own backend, but what about the case in which we are using third-party API?

    • @SamMeechWard
      @SamMeechWard  Рік тому +2

      This method only works if you're serving your react app from the same backend that you're making requests to. So you wouldn't be able to do this with a third party API, but those should already have the correct CORS configurations to allow you to make requests.

    • @mubashirwaheed474
      @mubashirwaheed474 Рік тому +1

      @@SamMeechWard The API endpoint I was using didn't have CORS configured so I used a proxy to fix the issue
      Thanks

    • @pjborowiecki2577
      @pjborowiecki2577 Рік тому

      @@SamMeechWard Thank you so much! Glad to have found your video and it helped me a lot. The only issue I am facing now is that this way, other routes (e.g., /admin) won't work after build - I am seeing "cannot GET /admin" messages. Routing works perfectly fine in development and I am using React Router Dom v. 6. Would you be so kind to explain this or point in the right direction? Thanks again!
      EDIT: Think I just solved it by adding
      app.use("/admin", (req, res) => {
      res.sendFile(path.join(__dirname, "dist/index.html"));
      });
      to my server. Not sure whether this is a correct approach, but it does the trick. Still, Would love to hear how you would solve this. Thanks!

    • @kenthugo
      @kenthugo Рік тому

      @@mubashirwaheed474 Have you fixed the issue? I have tried using the video's fix but it does not work in Production.

    • @mubashirwaheed474
      @mubashirwaheed474 Рік тому

      @@kenthugoin order to fix my issue I used the netlify's serverless function to create a proxy (express server through which request is made to the api and then proxy -backend- send the data to the frontend

  • @fabianvieri1907
    @fabianvieri1907 Рік тому +1

    Great vids, one thing is there a way to automate the build process?

  • @chinwubachukwudi4483
    @chinwubachukwudi4483 Рік тому

    Thank you so much mate

  • @KhushalMali-pf6fv
    @KhushalMali-pf6fv 3 місяці тому

    Thank you sir

  • @yoslandymesa5560
    @yoslandymesa5560 Рік тому +2

    Hi Sir. The tutorial is great, but I got catch for the plugin that helps you to complete code, I think you call it Copilot, but I see so many copilot on VS code. Could you be specific which one are you using?

  • @adrn_en
    @adrn_en 11 місяців тому

    Thankyou so much!

  • @robfielding8566
    @robfielding8566 27 днів тому

    note that such a proxy is a trivial Go program. I had ChatGPT write a reverse proxy, and it got it 99% right on the first try. I set env var PUBLIC_URL="." while making a React app, and did this proxying. So I could do hot-editing of the app running at root. And... I could upload another copy of the app anywhere in the tree, and it worked. I am a backend guy, and it drives me nuts when I can't just tar up an app and drop it anywhere into the tree due to urls like "/images/logo.svg" like they own the whole tree. Should be able to upload a list of where the backend endpoints are too.
    CORS is only about the JavaScript sandbox complaining about code coming from different hosts. And yeah... the whole point of the proxy is to force JavaScript to treat it all as one sandbox.

  • @suyogsinnarkar3614
    @suyogsinnarkar3614 11 місяців тому

    thank you bro

  • @Lunolux
    @Lunolux Рік тому

    great video, thx

  • @modeocheng2190
    @modeocheng2190 Рік тому

    love it!

  • @danielgajewski
    @danielgajewski Рік тому

    Thank you bro!

  • @pawanbhatta8973
    @pawanbhatta8973 4 місяці тому

    Thank you

  • @KCODivyanshuKatyan
    @KCODivyanshuKatyan 7 місяців тому

    which extensions are you using for auto complete? nice explaination btw.

  • @vladimirkuzmenkov7285
    @vladimirkuzmenkov7285 10 місяців тому

    jeez man, you sure have huge eyes
    P.S. Thanks it helped!

  • @CuriousAnonDev
    @CuriousAnonDev Рік тому

    Thank you Sam :)

  • @jokerbanny
    @jokerbanny Рік тому

    Thack Thank Thank you very much ! 🥳

  • @yungrut6553
    @yungrut6553 3 місяці тому

    this was get for the CORS fixs and explanation but having never used railway before I got completely lost

  • @ramkumarchauhan3176
    @ramkumarchauhan3176 2 місяці тому

    Thanks sir

  • @diwakardayal954
    @diwakardayal954 7 місяців тому

    Thanks

  • @alextotun
    @alextotun Рік тому

    Great! Thanks.)

  • @ELMlKO
    @ELMlKO Рік тому

    real hero

  • @daydream3025
    @daydream3025 Рік тому

    Thank you man

  • @computefreely6898
    @computefreely6898 Рік тому

    Amazing

  • @dhaouiaziz6611
    @dhaouiaziz6611 Рік тому +1

    should i remove the proxy in prod ?

  • @pawankalyan9105
    @pawankalyan9105 Рік тому

    THANKS MANNNNNNNNNNN

  • @zonirinarakotoson6516
    @zonirinarakotoson6516 Рік тому

    Thank you so much

  • @MelakeselamMengistu
    @MelakeselamMengistu Рік тому

    Thank you for such a clear explanation on CORS and how to resolve related errors. Im facing slighly more issues as I have containerized the frontend react app and backend spring boot api and seeing this CORS errors. I tried to add @CrossOrigin on the spring boot endpoint and also tried to add the serverUrl on the axios.post call. But it is still coming with error like u explained since the ports are different. Both containers are deployed on an EC2 instance using docker-compose remotely. Any recommendation as to how to go about resolving the issue.
    Much appreciate it.