Setting up cookies in a React and Express App (locally and in production)

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • In this video I explain how you can set cookies from an express Backend to a react front end.
    This video explains how you can set cookies locally and in production on a https protocol.
    I cover things like the cookie same site attribute and how you should set them up.
    Link to How to Deploy a Mern stack application on a server just like heroku:
    • How to deploy a React ...
    Gist to starting react project: gist.github.co...
    Gist to complete Project:
    gist.github.co...

КОМЕНТАРІ • 43

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

    after watching your video i fall in love. you save me huge amount of stress. thank you so much

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

    Everywhere on the web talks about this setup but never the Proxy for both client/server. Thanks 🎉

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

    Thanks for the assistance I have been battling with the cookie not showing up in the application tab thinking the cookie was not been sent this video just solved a problem I have been on for days now
    Thanks keep it up

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

    Dude!!!! After two four days of hitting my head on the wall!! so simple... THANK YOU!🤩

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

    I forgot to add "withCredentials":true in the POST request as well
    Thanks Man!

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

    Thankyou so much bro,Real i was struggling from 2 days because of you i made express-session and passport-local strategy able to work.Thanks a lot

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

    Hi, great stuff man, I was struggling for hours, and after your video I done more in 20min than entire day today because of the two options for cors and client side headers... Thank you so much, you have a subscriber.

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

    Thanks Bro, I try to set cookie from yesterday but after watch your video i finally got it. 😁

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

    Thank you for the video I managed to solve this problem I've been having for 3 days

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

    Thank you very much. Solved my issue with the proxy option.

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

    thanks for your tutorial which save my cors problem just in time!!😆

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

    Man thank you so much. I really needed this!!

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

    Thanks a lot this will solve my issue

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

    Thanks Man, you solved my problems

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

    Great tutorail you solve big problem

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

    man you saved my day

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

    thak you bro . this video was very helpful

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

    Absolutely Amazing Video!!!❤

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

    very helpful and informative video.

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

    Dude, You are a star

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

    I cant make it work with Next.js on frontend / Express.js on backend. Set-Cookie is preent on response but its not being set no Chrome/Firefox. As soon as I put the 'withCredentials: true' I get CORS error ('strict-origin-when-cross-origin'). On postman it gets set. I tried every single possible config combination, no idea what else to do. I haven't used express-session. Any thoughts?

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

      same issue. Did you get any fix?

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

      @@advay6449 yes, my error was that I had on my express app.options('*' cors()) and that sets default setting for every route on my express app. I removed that line

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

      @@abelmurua6980 okay, ill try that out

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

    had to use subtitles!! but video is great

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

    how get cookie store browser in reactjs from nodejs backend program?

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

    Thanks so much for this.

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

    Hi, thanks for the video. I try to exactly do the same with the video. In the production site, whenever I open the site in desktop it works well, but if I open from the phone (Iphone and Samsung), I always got an error, error that I mean is cookie is not stored in the mobile browser. Anyone face same issue or can help?

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

    Thankyou so much!

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

    Thanks

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

    Thank you so much

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

    Thank you for this amazing tutorial. Quick question. Does this still work if the frontend is on firebase and backend on Heroku. Thanks in advance.

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

      Yes this should work as long as its over a HTTPS connection

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

      @@webbase8836 Thank you very much, I read that you cannot send cookies over different domains, however, I do see people doing it, so I was confused. Thank you again!

  • @558dhananitejendra7
    @558dhananitejendra7 Рік тому

    That means everytime to read cookie I've to make a http request to server. Wouldn't it degrade the performance ? Any alternative way to do the same .?

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

      You can just opt in for Json web tokens

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

    hi man! nice video worked for me,
    Just a small improvement for your videos, make them shorter and when everything works, so your audience wants to enter to see 10 minutes instead of 35m (that sells a lot) and if you think necessary, you can upload a second video without editing for the curious user.
    happy codding!

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

      I for one enjoy seeing the errors and the way to go around them

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

      @@bonganintshangase6051 yep, but not when you are in a hurry! haha

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

      Actually, the errors are the best part, at least for me.

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

      errors are very important

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

    thanks you

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

    thanks a lot , you debbug me