CORS in 100 Seconds

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • Cross-Origin Resource Sharing or CORS is a mechanism that allows browsers to request data from 3rd party URLs (or origins) and is a common pain point for web developers. Learn the basics of CORS in 100 seconds.
    Full Tutorials
    Use CORS in Firebase Cloud Functions fireship.io/le...
    Helpful CORS Resources
    web.dev/cross-...
    developer.mozi...
    #webdev #js #100SecondsOfCode
    Install the quiz app 🤓
    iOS itunes.apple.c...
    Android play.google.co...
    Upgrade to Fireship PRO at fireship.io/pro
    Use code lORhwXd2 for 25% off your first payment.
    My VS Code Theme
    - Atom One Dark
    - vscode-icons
    - Fira Code Font

Комментарии • 587

  • @Fireship
    @Fireship  3 года назад +769

    *correction a cross-origin image fetched with an tag is not subject to CORS, it to comes into play with HTTP calls from scripts, ie fetch() or XMLHttpRequest

    • @Michael-rc5ks
      @Michael-rc5ks 3 года назад +15

      Oh wow you actually made the video on CORS. Really fast as well! Very nice!

    • @htmixl
      @htmixl 3 года назад +9

      What about cors beyond 100 seconds, i have had some troubles setting up httpOnly cookies with cors. Or some video about httpOnly cookies.

    • @MaulikParmar210
      @MaulikParmar210 3 года назад +3

      Combine this with CSP and you have nice security setup that prevents unauthorised execution and injection.
      May be do 100s on that to complete the cycle xD

    • @Heylow1
      @Heylow1 3 года назад +7

      Annoyingly, fonts are subject to cors

    • @krzysztofprzybylski2750
      @krzysztofprzybylski2750 3 года назад +3

      I would add that a tokenized request cannot be wildcarded. It. Caused. So. Much. Pain

  • @DavidDeCorso
    @DavidDeCorso 3 года назад +1229

    That error screenshot gave me PTSD

    • @joopie46614
      @joopie46614 3 года назад +35

      lucky, i get ptsd every time i see the colour red

    • @qwerasdfhjkio
      @qwerasdfhjkio 3 года назад +3

      lol

    • @AlexTheGreatish
      @AlexTheGreatish 3 года назад +14

      Laravel and CORS errors are the things I fear most in life.

    • @justamanchimp
      @justamanchimp 3 года назад +2

      Literally 😂

    • @alphaNaj
      @alphaNaj 3 года назад +1

      lol

  • @SillyNaughty
    @SillyNaughty 3 года назад +2

    Ugh I ran into Cors a few months ago. Painful. These videos are excellent, clean and digestible; Whilst not disrespecting the audience's intelligence with over explanation. Nice work man!

  • @mrverdant13
    @mrverdant13 3 года назад

    Dude! A couple of weeks ago I needed this!
    You're saving lots of valuable minutes!

  • @blakef.8566
    @blakef.8566 Год назад

    I don't understand why the preflight is needed? If a server is going to block a request, why not just find out at the time the request is made? What's the advantage to knowing before hand? Great video, has made things click for me!

  • @onhazrat
    @onhazrat Год назад +2

    🎯 Key Takeaways for quick navigation:
    00:00 🌐 Cross-Origin Resource Sharing (CORS) allows websites on one URL to request data from a different URL, but it can be frustrating for developers.
    00:30 🔒 The Same-Origin Policy in browsers allows requests from the same URL but blocks external requests unless specific conditions are met.
    00:58 🚫 Mismatch between the "Origin" header in the request and the "Access-Control-Allow-Origin" header in the server's response results in CORS errors.
    01:12 🛠️ To solve CORS issues, configure the server to include the appropriate CORS headers in the response.
    01:41 ✈️ Certain HTTP requests, like "PUT," may require preflight checks to ensure they are safe to execute on the server.
    02:08 🔄 Check for the "Access-Control-Allow-Origin" header in the network tab to diagnose CORS issues, and make sure it matches the website's URL and allows the necessary methods or headers.
    Made with HARPA AI

  • @alinaqvi385
    @alinaqvi385 2 года назад

    I like the body scan by the security guy.

  • @Allstreamer_
    @Allstreamer_ 3 года назад

    Thank god for this video, also where do you find this kind of info

  • @Wakkyguy
    @Wakkyguy 3 года назад +3

    Golang 100 seconds and beyond

  • @africayean1311
    @africayean1311 3 года назад

    can you say something about curl - PHP

  • @JAAulde
    @JAAulde 3 года назад +1

    CORS is something for which I understand the mechanics, but can't get my head around how it protects the client side. If I'm a bad actor and have somehow caused a browser to make a cross-origin request, I'll just make it send that request to a bad-actor server that I own, which server I'll configure to allow requests from anywhere. Can someone help me understand how CORS really protects the browser when the 3rd party server dictates what's allowed? I'm sure it's me that's missing something, and would love to have some light shed on it.

    • @Fireship
      @Fireship  3 года назад +1

      I believe the main motivation is cookies. A bad site could send a request to a legit site with your cookies.

    • @JAAulde
      @JAAulde 3 года назад

      @@Fireship hmm, ok. Thanks for the reply, I’ll have to think that through. 🙂

    • @JAAulde
      @JAAulde 3 года назад

      Oooh, ok, I do get that scenario. That makes good sense, thank you!

  • @lardosian
    @lardosian 3 года назад +1145

    Cors errors can really push ones patience to the limit!

    • @Heylow1
      @Heylow1 3 года назад +37

      Especially when you're using a framework, so that any custom cors fixes you might make, will seem to not work at all, until you realise a hundred other functions precede your code

    • @vishalkhandate2464
      @vishalkhandate2464 3 года назад +30

      100% Correct. CORS Error is something you think you can fix but still cannot fix it. Trying Trying Trying .Panic!!!🙂

    • @adamhenriksson6007
      @adamhenriksson6007 3 года назад +17

      The trick is to use a CORS proxy because you have no idea what you are doing, but then you will be very sad when you realize that all traffic is running through a third party, and even more sad when that proxy goes down and bricks your prod site. I've seen implementations like this IRL and it's not fun to watch.

    • @Name-lt2tz
      @Name-lt2tz 3 года назад +2

      yea, why they dont tell better in the errros what to do. Just give errors you cannot fix

    • @Name-lt2tz
      @Name-lt2tz 3 года назад

      like I have working web witout cors errors, but when in file upload image is too big- it gives cors error. wtf. why it has to act differently when file is above limit size

  • @gokuldinesh8851
    @gokuldinesh8851 3 года назад +337

    Makes a poll. Listen to the audience. Clears their doubts
    10/10 love your channel

  • @afiefsholichuddin
    @afiefsholichuddin 3 года назад +169

    You forgot to mention the "it is working on postman" part haha
    although it is related to browser and different domain part

    • @ChrisHaupt
      @ChrisHaupt 3 года назад +7

      This was one of the first ever giant problems I ran in to as a guppie developer. Forgot about it too, thanks for the reminder!

    • @ArthurKhazbs
      @ArthurKhazbs 2 года назад +7

      By Postman you meant Insomnia*

    • @BalconysHD
      @BalconysHD 5 месяцев назад +2

      WAIT WHAT THE HELL, IT IS WORKING ON POSTMAN BUT NOT ON CLIENT WTF IS GOING ON

    • @afiefsholichuddin
      @afiefsholichuddin 5 месяцев назад

      @@BalconysHD because postman desktop app is not a browser, try with posting web version

    • @afiefsholichuddin
      @afiefsholichuddin 5 месяцев назад

      @@ArthurKhazbs insomnia has become postman too now

  • @paddyspencer6762
    @paddyspencer6762 3 года назад +401

    I literally was just needing this lmao

  • @muradmorshed
    @muradmorshed 3 года назад +413

    fireship is the hero we need, but we definitely don't deserve.
    it's weird seeing free content with such high quality 🥰🥰🥰

    • @moshyfawn
      @moshyfawn 3 года назад +7

      Well, u haven't seen enough open-source projects then. Some people are crazy smart and so good at their stuff + they provide those for free. It's insane! Many kudos to the Fireship creator(s)!

    • @prateekrohilla
      @prateekrohilla 3 года назад +2

      @@moshyfawn do you know any amazing react open source projects, i have just started so reading some code might really help

    • @Dreez
      @Dreez 3 года назад

      u pay with ads.. but thats ok

    • @deepak8586
      @deepak8586 3 года назад

      Bruh you high??

  • @WolfrostWasTaken
    @WolfrostWasTaken 3 года назад +258

    Be careful! Sometimes you might get an error saying that CORS blocked the request because the OPTIONS call does not have an HTTP OK status. This actually has nothing to do with CORS (it's a red herring), but rather the route itself is missing from the server, or the server isn't responding correctly. Beware!

    • @stepankotyk8823
      @stepankotyk8823 3 года назад +20

      :D if server responded with 5XX error, angular can throw CORS error into console. So many confusing issues with this in my life

    • @WolfrostWasTaken
      @WolfrostWasTaken 3 года назад +5

      @@stepankotyk8823 True ^^ I always check the full error string before assuming it's a CORS problem, and ofc check if the preflight request goes well

    • @ataraxieabrutissante267
      @ataraxieabrutissante267 3 года назад +6

      Postman is your friend

    • @complex5372
      @complex5372 3 года назад +2

      Nice. Thanks for sharing.

    • @stepankotyk8823
      @stepankotyk8823 3 года назад +2

      @@ataraxieabrutissante267 how is postman related to CrossOrigin requests

  • @FalseDev
    @FalseDev 3 года назад +55

    I thought I understood CORS well until 5 minutes ago 😆
    Very informative video as always!

  • @69k_gold
    @69k_gold Год назад +7

    I feel like the entire field of computer networks is creating a way to connect two nodes and then trying their best to avoid doing that by default

  • @starkxz
    @starkxz 3 года назад +140

    You do always listen to the audience requests, and that's what a good content creator do. Thanks Jeff.

    • @mfaizsyahmi
      @mfaizsyahmi 3 года назад +12

      he set his Access-Control-Allow-Origin to *

    • @nald-dev
      @nald-dev 3 года назад +6

      The audience make a request, fireship give them 200 ok

    • @starkxz
      @starkxz 3 года назад

      I was preparing for a front-end exam yesterday when I got to the AJAX part, I've glimpsed the CORS section, well in that moment I knew it's not funny any more because the exam system is pen and paper no machine. Knowing that JS have some weird behaviors made me re-think my life choices

  • @xrr-1
    @xrr-1 3 года назад +80

    So, I'll tell my manager that this is something that the backend devs should fix.
    PS: I'm frontend

    • @kyrierevival3658
      @kyrierevival3658 3 года назад

      both frontend and backend.

    • @codiumyt
      @codiumyt 3 года назад

      Or use CORS Anywhere (google it)

    • @xrr-1
      @xrr-1 3 года назад +1

      @@codiumyt Don't want to raise a PR that gets a bunch of comments

    • @justamanchimp
      @justamanchimp 3 года назад

      This is why it's so important for any type of web developer to learn the fundamentals and basics of how browsers interact with servers, and the fundamentals of how the HTTP protocol works. Most generic guides of these subjects talk about CORS and how it works. I wish I understood it sooner!

    • @user72974
      @user72974 3 года назад +1

      Yes. CORS is a back end only issue. There are things you can do on the front end to get around it (like usual browser extensions to disable it while testing, or running a proxy to make requests through) but for production it needs to be fixed in the back end, since CORS is a security feature where a back end decides what kind of requests are allowed to be made by front ends on different domains, and what those domains are.

  • @programmingpython584
    @programmingpython584 Год назад +3

    I am using a third party api, so i don't have the backend control and got the CORS error. Now i guessed one fix (and that worked). I created my own backend (in node) and called the api there and allowed my frontend domain to access my local backend (as that was giving the cors error too). Now i can easily get the data on frontend served by my backend which is actually coming from a 3rd party api. This is infact a common fix in this case as by having a custom backend, we bypass the browser security.

    • @anthonylosego
      @anthonylosego Месяц назад

      This is not necessarily the reason for the error so much as MOST apps use a back end express or some other server to serve up data. Meaning the server takes the load by default. But if you are programming a single app to just go get the data (say a single REACT app with no backend or "middleware") it will fail. We know most 3rd party apps are providing data they want you to access with tokens or secrets, what have you (and you don't have control of those servers either), yet the front end will fail due to client security issues. Seems extremely wasteful to create an intermediate middleware just to retrieve data, but I'm pursuing a middleware solution now due to this strange conflict. Not ideal. But I'm rolling with it.

  • @Trixz-the
    @Trixz-the 3 года назад +27

    I've been waiting for this for weeks!!!

  • @rifaldhiaw
    @rifaldhiaw 3 года назад +23

    Please do more something fundamentals like this. Some mainstream frameworks are easy to look for documentation. But IDK y, something like this sometimes gives a headache

  • @anand.prasad502
    @anand.prasad502 3 года назад +14

    So Fireship uses Firefox ! :)

    • @dfla5472
      @dfla5472 3 года назад +2

      Also Firebase.

    • @peco3221
      @peco3221 3 года назад +1

      I also use FireFox, it is awesome

  • @jonathanlonnfors3220
    @jonathanlonnfors3220 3 года назад +20

    literally had CORS problem today and now I understand it better. And this is not the first time you read my mind and make videos of it the exact same day.
    Plz keep it up i need you!

  • @narutokunn
    @narutokunn 3 года назад +4

    Recently I was able to bypass cors issue by opening chrome with no security And user data dir flags. How are we able to bypass this? Isn't this a security vulnerability? Some browser extensions also let us bypass cors error.

    • @pokefreak2112
      @pokefreak2112 3 года назад

      I'm not an expert but I'm pretty sure CORS is supposed to be a client-side security feature, not a server side one. If you decide to disable CORS in your client that's on you.

    • @Heylow1
      @Heylow1 3 года назад

      CORS is a browser safety feature, so if a user chooses to do what you did, then yes, it's a vulnerability, just as it would be if e.g you hacked your browser to allow JS to access local files.
      In regards to server security, that should not rely on CORS, but on authorisation and authentication, such as JWT, oAuth or the like

  • @dennism3586
    @dennism3586 3 года назад +8

    It amazes me how even after years of schooling I still learn stuff from 100 second videos. Keep it up!

  • @ProjectExMachina
    @ProjectExMachina 3 года назад +4

    Me: I got the CORS error
    Server dude: What is that?
    Me: *Silently quotes Geralt when presented with the ultimatum

  • @Yaxqb
    @Yaxqb 3 года назад +1

    To login to my site /login over axios, I require a CSRF token
    That token is gotten through doing a GET to /set-cookie
    For 3 days, I've tried to figure why document.cookie is empty
    Turns out, I have to pass {withCredentials: true} even if I'm not submitting any credentials, just receiving them
    Also, if you change your content-type (in axios) to text/plain, CORS stops complaining
    I hate my life and JavaScript and CORS and CSRF

  • @Patrick_Bard
    @Patrick_Bard 2 года назад +1

    "If you don't control the server you are out of luck" is a bit misleading. Some servers, especially APIs, may have options to enable it.
    For example, I used Wikipedia API on a Unity project, it works just fine on the editor, but it gave CORS error when running a build version. The solution was simply add a parameter to the API call.

  • @magne6049
    @magne6049 3 года назад +1

    0:53 Isn't it supposed to be `Access-Control-Allow-Origin: foo.com` ? It doesn't make sense that bar.com would send back "allow bar.com to access my resources".

  • @codrutx
    @codrutx 8 месяцев назад +1

    I had a problem with a PHP API server at some point. It seems POST requests require a preflight check or something like that, because I had the CORS headers all set up, but I had a statement if the request was blank, return 503. And that messed up the CORS preflight as the preflight Is sent with an empty request.

  • @prayk11
    @prayk11 2 года назад +4

    I legitimately love this video. Through my few years with web development I got so many CORS errors that the error screen gives me PTSD. This video really clarifies the concept real quick. I wish I had seen it when I got my first CORS error.

  • @Webh2kker
    @Webh2kker 3 года назад +1

    @fireship "if you don't control the server then you are out of luck"? server sided request proxy? cors only works for browsers so if you make a request with your own server it is not blocked and you can set it up to give you proxied results.

  • @aryankumar87771
    @aryankumar87771 2 года назад +1

    god tier explanation in 100 seconds meanwhile other youtubers wasted my 20 minutes and left me confused

  • @tanaygupta6905
    @tanaygupta6905 2 года назад +1

    If this video didn't exist, then probably I would have thrown my brain🙂

  • @HamaadSiddiqui
    @HamaadSiddiqui 3 года назад +1

    How to get rid of JavaScript Fatigue in 100 seconds ? 🤞😅

  • @Mouamle
    @Mouamle 3 года назад +1

    I've been writing backend code for 3 years now and to this day i keep getting sleepless nights because of CORS

  • @joshuaenricksalvador1544
    @joshuaenricksalvador1544 3 года назад +3

    Wow, I've had this problem for months, at some point I just decided to copy whatever solutions I could find and see if it would work, but it was always different depending on the project. This really explained the whole error response thing, I could never really understand the different CORS errors.

  • @Alessandro-nq3tm
    @Alessandro-nq3tm 3 года назад +5

    Great! Another important thing to say is that you can allow multiple origins simply specifing them divided by commas, instead of using the wildcard

    • @Savics_dev
      @Savics_dev 2 года назад

      Can you put me through

    • @Real_JKDOS
      @Real_JKDOS 2 месяца назад

      Maybe it's different on some servers, but adding commas is not allowed. It needs to be 1 explicit host or wildcard.

  • @itsbk6192
    @itsbk6192 3 года назад +1

    You really need to put a trigger warning before you go throwing cors errors around willy nilly

  • @nulled7888
    @nulled7888 3 года назад +1

    Nice music btw. Selfmade or can you name me an artist? :)

  • @DevanKS
    @DevanKS 3 года назад +1

    Oh my God. CORS has been hell for me when we work with a local development environment. Kills minutes of my life.

  • @laffed2045
    @laffed2045 3 года назад +3

    we asked and he delivered. One of the many reasons why Fireship is the best dev channel on youtube

  • @JoshuaMcDonald1992
    @JoshuaMcDonald1992 3 года назад +13

    needed. so much needed

  • @codiumyt
    @codiumyt 3 года назад +3

    Fireship: If you don't control the server, you're out of luck
    Me: Proxifies the request using CORS anywhere

    • @steffenderfreak1
      @steffenderfreak1 3 года назад

      Please, Don't proxy. Unless you are fully in charge of the proxy, you Don't know, who logs your data and for what reason.
      Also, if the proxy is down, your code don't run. Also, in companies, you could have the issue, that your proxy ist blacklisted in the network-firewall.
      There are 1000 more reasons, not to proxy, so, don't do it. It's unsecure, slows the request down and adds an extra level of network-complexity

    • @codiumyt
      @codiumyt 3 года назад

      @@steffenderfreak1 We have full control over our proxy, hosted on the same server as our website. There is no downside of using it.

    • @steffenderfreak1
      @steffenderfreak1 3 года назад

      @@codiumyt and why aren't you set up yout backend properly? I'm just curious

    • @codiumyt
      @codiumyt 3 года назад

      @@steffenderfreak1 I think you missed the point of my comment. I explicitly stated that I *don't* have control over the server.

    • @steffenderfreak1
      @steffenderfreak1 3 года назад

      @@codiumyt ah OK, sorry. Yes, I missed this.

  • @john_smith281
    @john_smith281 3 года назад +1

    In Node js setting headers decrease performance.
    You need just this header for every request:
    - Access-Control-Allow-Origin
    - Access-Control-Allow-Credentials
    - Access-Control-Allow-Headers
    The other header is only need for the preflight request (method Options):
    - Access-Control-Allow-Methods
    So checking in a middleware if the method is OPTIONS and set this header too. Otherwise set just the other headers in this mw.

  • @PhoenixStudios147
    @PhoenixStudios147 3 года назад

    here's a neat idea: a feature for sites to request the user's permission to override CORS security via a browser popup, with clear explanations of what security issues this may cause. Main use that prompted this idea was for me to make custom media viewers for say radio sites.

    • @neoqueto
      @neoqueto 2 года назад

      7 different popups on a website is not enough, we need 8.

  • @karanparmar4318
    @karanparmar4318 3 года назад +1

    Thank you for clarifying my doubts,
    But Need Beyond 100 seconds for CORS would be super helpful too.

  • @muneebmohd
    @muneebmohd 2 года назад +1

    You are the prophet of Web developers!

  • @madsouris
    @madsouris 3 года назад

    I got the error on my Netlify site (Vite, Vue, Tailwind), gave me headache cuz my noob ass can't figure out.
    Turn out disabled asset optimization in dashboard solved the problem

  • @tsabudh
    @tsabudh 9 месяцев назад +1

    I was preparing myself to watch a video of hours to understand CORS. Fireship came to the rescue. It surely built at least the fundamentals. Great content as always.

  • @CharleyWright-w1y
    @CharleyWright-w1y 3 года назад +1

    You can also make a cors proxy using nginx and proxy_pass although you shouldn't have a reason to 😉

  • @ananthuskumar1286
    @ananthuskumar1286 Год назад +1

    I finally understood CORS. Thanks mate.

  • @harukaeru-en
    @harukaeru-en 3 года назад

    Access-Control-Allow-Origin Header: Exists
    Browser: Error!! We can't send this request. There is no Access-Control-Allow-Origin Header
    Me: F***

  • @soniablanche5672
    @soniablanche5672 3 года назад

    but ignores CORS policy (actually all HTTP requests made by the HTML engine ignore it, including POST/GET requests from a ) , if it's broken it's for another reason.

  • @stevenlayne6454
    @stevenlayne6454 3 года назад

    I could have REALLY used this when I was first discovering CORS was a thing. And y'all know that wasn't a pleasant experience...

  • @amilismurfs
    @amilismurfs 3 года назад +1

    How quickly are you able to create these awesome videos? I remember yesterday when I read someone suggesting this video and here it is. I'm amazed.

  • @addanametocontinue
    @addanametocontinue 3 года назад

    CORS: Creating headaches for people developing standalone javascript tools since... I dunno, whenever.

  • @diabolo1
    @diabolo1 3 года назад

    Excelent work... Although i'm still not clear what "preflighted" means...

  • @IrregularPineapples
    @IrregularPineapples 3 года назад

    You didn't explain what CORS is for or why it's used. "Security reasons" is both vague and inaccurate. The practical reason is to give Web Servers control and help mitigate abuse. It works because most people use modern browsers that adhere to the CORS policy (as opposed to hacked/forked version of browser without it). It has no implications for security as it doesn't prevent access at all nor have any implication for code not executed on the client side. It prevents other sites from (ab)using a third party API without permission. Why? Because browser makers and web site creators have deemed that it makes for a better web overall. And they're right. Otherwise e.g. any site could just use RUclipss public search API as their own -- now they can still technically do that, but they will have to do it by hosting a server proxy themselves (which is both much more effort and much more easily detectable by RUclips) -- and not simply have the visitors browser to their site make the request to RUclips's API Server (AKA leeching).

  • @double_courage57
    @double_courage57 3 года назад +1

    Nice selection of font. I so wish to have a chilled Coors Light right now!

  • @martingraizely
    @martingraizely 2 года назад +1

    Love you guys! This is short, simple and down to the business. First time I had to slow down the vid and I was glad

  • @neoqueto
    @neoqueto 2 года назад

    It sucks that everything on the web is slowly becoming centralized, without server access you can't really do a lot anymore, it used to be simpler.
    People like using Python for any kind of general purpose scripting, but personally I prefer JS, in the browser, always whipping up a nice GUI for myself. And guess what, can't even use it, can't even fetch some JSON from an API, despite JSON literally having JS in its name... CORS should be disabled for anything being run from localhost altogether, or there should be a simple switch in the browser settings for developers who just want to fiddle around. But no, download Node, download Apache, download nginx, run server, blah blah, nothing works on Windows, because console syntax is always different compared to documentation, so you need a Linux VM, or WSL2, and it just fucking sucks. Just let me play around with APIs. It's my goddamn computer, it's my own goddamn browser, my trash code is not a product I'll ever ship or even publish.
    And I understand that not every public API provider wants their API to be used by any client. I'm saying that if you are running your site off of a server you can accept public API responses, but without a server, if it's just a .html file running from localhost, you won't be able to communicate with no API whatsoever.

  • @Real_JKDOS
    @Real_JKDOS 2 месяца назад

    In my experience, the best solution is to just allow origin with a wildcard, unless you're setting up a private endpoint for 1 specific client/server.

  • @YosepRA
    @YosepRA 3 года назад

    And often their error messages are _too helpful_ thaf I can't help but cry hard reading it.
    Yes... It just happened last night. And it wasn't a "normal" CORS error like Origin error. 💔

  • @AtizaJuanita
    @AtizaJuanita 3 года назад

    Ok I know I'm gonna get some hateful replies here but I DO see this channel becoming the largest software development community in the future. Surpassing channels like Traversy Media.

  • @101kawsar
    @101kawsar 2 года назад

    I am Django developer and never have to worry about this. Just install a package (django-cors-header) and write some lines of code and never worry about it again, everything just works.

  • @donaldklopper
    @donaldklopper 3 года назад

    And now you've just put 13500 "expert consultants" out of work by sharing these secrets. Have you no shame?

  • @xtechoracle
    @xtechoracle 2 года назад

    First video I'm seeing from fireship with speaking pace/speed normal enough to be comprehensible ..
    I'd like to see more video of u talking in a normal pace, not rushing things like you're been chased !!
    Thanks for this though 👍😘

  • @sidikriders3007
    @sidikriders3007 3 года назад

    I have a problem in my server, it didn't allow PUT or PATCH method in google chrome, but in firefox it works fine lol

  • @jakubwegrzyn3798
    @jakubwegrzyn3798 3 года назад +4

    First

  • @gauravvarma3645
    @gauravvarma3645 Год назад

    This video is sort of mid. If the origin is the same but the path is different then the browser can still make that request (you were saying the url has the be the exact same which isn't true).
    Also an explanation of the why behind Same Origin Policy would be nice. If you curious, SOP is basically there to protect malicious websites from taking the users cookie data and then sending calls to other sites (of different origin) and getting their personal data.
    Anyways, I am a big fan of your content, keep up the good work :)

  • @akshay3538
    @akshay3538 3 года назад

    CORS is a b*tch, hate it, nice video, i hate it even more. but now i understand it much better. Also Having a 100sec video is a good thing for someone who is looking for a quick insight, but a beyond 100sec version will do more good.

  • @csongorszecska
    @csongorszecska 3 года назад

    This mfing policy makes it literally impossible to create 100% offline HTML-js-css applications and I hate it more than anything else

  • @FrenchyFrencher
    @FrenchyFrencher Год назад

    It's a great attempt but there are some serious omissions. For example, at 1:24 and 1:49 you fail to mention which server it is that you're referring to. CORS is about a client and 2 different servers/domains, right? It's important to understand which one you're talking about.

  • @MaZe741
    @MaZe741 3 года назад

    I hated cors errors when I started webdevelopping. It even hits you into the knee when developping locally, like COME ON.

  • @erlendtryti
    @erlendtryti 3 года назад

    spent an entire day trying to fix CORS that were seemingly all correct. Turns out the browser had cached the CORS before I fixed it. 🙂😢

  • @ShaffleOne
    @ShaffleOne 2 года назад

    How the hell you do that?? I'm trying to understand CORS for a day already, YOU DID IT IN 100 SECS WHAT

  • @rd_45
    @rd_45 Год назад

    Very good content,like always. Thanks for that.
    But is it really explained in 100 seconds 😉?

  • @firstnamelastname4183
    @firstnamelastname4183 3 года назад +1

    This was extremely clear and concise! Much better than reading all those confusing articles online

  • @Jubinmail
    @Jubinmail 3 года назад

    Can someone rollback the Firefox Logo already.
    edit: Oh fuck me. The older logo is still alive and well. The one shown in the video is of their 'parent brand'.

  • @ascetahedonista7161
    @ascetahedonista7161 3 года назад

    Last month I get a souposed cors error moving mi app to a new server, at least that what Firefox was saying. In reallity a network restriction was avoiding my API to find the database server causing a sqlexception and then returning a 500 error for every call to my API. The 500 error response was sended back to the client browser without any header and axios in the client browser just take care about that last thing and only that thing and claimed that the problem was cors whitout say anything about a 500 error or it's message content.
    It was painful.

  • @ninjaasmoke
    @ninjaasmoke 3 года назад

    Was learning MERN stack, hated dealing with this.
    Now I just add a wild card and make sure that my web app is unsafe, but working

  • @Spacetime23
    @Spacetime23 10 месяцев назад

    didn't get the whole technicality though.. but I understood what I need to understand as a beginner in Front End Development.. Thanks

  • @SrijalPlayz
    @SrijalPlayz 4 месяца назад

    saved me!!! i didn't know about this. It was plauging my code and finally fixed it after a whole day.

  • @Abdullah_Osama
    @Abdullah_Osama 3 года назад

    Hah Jokes on you, I run chrome without CORS policy Via the commandline
    In reality this is very dangerous and could get your data stolen please don't do that

  • @meeeeeeeeeeee
    @meeeeeeeeeeee 2 года назад

    How to use CORS:
    1. Wide enable everything.
    2. Move on with your life.

  • @dushmanta05
    @dushmanta05 Месяц назад

    Wow! I'm amazed by how you explain it with ease. Thanks Jeff!

  • @arntxy
    @arntxy 3 года назад

    Cors is the dumbest “security feature” in browsers since it does not protect against anything. Literally, anything. It just make front end devs lose their patience.

  • @elementiro
    @elementiro 3 года назад

    Ok, server, cool. But what if I just want to run a static website with JS scripts attached, both living in the same directory on my local hard drive, huh? How can I tell browser in that case to let these scripts be imported?

  • @acutchin
    @acutchin Год назад

    Thank you not at all for such a confusing non-explanation of CORS. Looking for better sources now.

  • @dan-san
    @dan-san 3 года назад

    The special take away here is "if you have access to the backend". When you don't, things like a reverse proxy or the unsafe mode of Chrome are your saviors.

  • @fordneild2372
    @fordneild2372 3 года назад

    I wish this video existed 3 years ago lol. The MDN docs on this r so confusing. I guess the next generation will be better taught/prepared

  • @earthling_parth
    @earthling_parth 3 года назад

    I just voted on the most anything YT community post on CORS. YASSSS!!!!

  • @ricardoamendoeira3800
    @ricardoamendoeira3800 3 года назад

    Big brain solution: Implement your entire backend API as dynamically created image files

  • @kha9770
    @kha9770 3 года назад

    The browsers implemented this as part of their security model - but I have no control of the remote service to allow/block same origin... Still struggling on the rationale behind this

  • @thatsalot3577
    @thatsalot3577 Год назад

    Things to check
    - check the url for typos
    - check for internet connection
    - check for headers (access-control-allow-origin)
    If these are fine you're good to go

  • @smith4591
    @smith4591 Год назад

    Resources sharing between different origins should ban internationally. Then finally developers can have peace.