Understanding CORS with ASP.NET Core C#

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

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

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

    Epic explanation! Gets directly into the golden collection 😍Thank you!

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

    Well explained. I understand it a bit better now. I already knew how to fix the errors but this added a bit more depth to my understanding. I never saw it done the manual way before, it makes more sense. Thanks.

  • @READBOOKIQBAL
    @READBOOKIQBAL 29 วันที่ผ่านมา

    Great work ! Keep it up. Really appreciable !

  • @user-fd3yr5eo4g
    @user-fd3yr5eo4g 11 หลายเดือนก่อน

    Well explained, one of the best video I have watched for CORS. Thanks for that.

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

    Another great well explained video. Thanks heaps for making it.

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

    Thank you, thank you and thank you! Finally I got to understand this topic. Really well explained as always. Again thanks!

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

    Very informative like no other. Thank you!

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

    Good explanation. Thank you

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

    Nice clear overview! If you needed to dynamically apply CORS configuration based on the request (which origin, is the request authenticated, ect...) can this be done with the built-in ASPNET Core "UseCors" middleware or should this be a completely custom built middleware?

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

      As mentioned at 15:42, you're better off using an existing CORS middleware library, in particular because implementing CORS "from scratch" (unless you're intimately familiar with the protocol) is error-prone.

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

    Thanks Anton for the awesome video
    how to load origins dynamically from database ?

  • @user-fj2oe5cl8j
    @user-fj2oe5cl8j 7 หลายเดือนก่อน

    You are a god thank you. very nice video💙

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

    I have several POST endpoints in my controller, how can I allow CORS only for one of them and disallow it for others?

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

      You would create a named policy like he does in the video towards the end. The difference is you don't enable CORS everywhere with app.UseCors(...); instead you enable it on the endpoint with an attribute: [EnableCors("Policy1")].

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

    I have one question about the first part of the video. Unless I missed it, there was no preflight request for "Access-Control-Allow-Origin". Is it implicit? The server still has to first reply, and tell the browser that it allows CORS, right?

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

    are you reading my messages?? I literally just asked this question holy shi* man holy falgget blacakaty magati shiiii- Thank Yoouuuu

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

    Still trying to figure out what CORS actually protects from: CORS is easily bypassed, for starters. As soon as you have the server set up to allow certain origins, methods, etc, then you no longer have the same security level (the session mechanism will be sent over just like normal). I don't get how this helps with security.

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

    As someone not already familiar with CORS at this depth I found this a little too fast. Especially when it came to the allow credentials part where Creds and "cookies" seem to get conflated and from the point I was completely lost. Will have re-watch to see if I can unpick it.

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

      if you implement cross origin authentication, you'll quickly realise how to fix it using that header.

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

      @@RawCoding for example if you use identity4 for your own api, client and server auth, i came across this issue, ?

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

    Liked And Already Subscribed Bro

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

    That minimal api apps are very confusing - I'm missing the part where OtherApp is calling an API. EDIT: Nvm - fetching a server app from otherapp console does this.

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

    Thanks for well explained video, can I use CORS to allow or disallow calls to my APIs from mobile apps ? if yes How to do so ?

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

      Did you miss the part where it’s a browser security feature?

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

      @@RawCoding Seems I did, What is the best way to secure my APIs ?

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

      Put it on a private network

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

    I've been reading and looking around to understand CORS and I got a pretty good idea about it now. I have a problem where the preflight, when my webapi is deployed to the server, always returns a 401 Unauthorized. I'm calling the webapi from a vue-site installed on the same server but different site and port. I used the app.useCors but it still didn't work when deployed. So then I expliclty put the headers for allowing origins but I still get the 401 from the preflight/OPTIONS request. In chrome I don't see the allow-origins header on for the options request and the console says the header is missing but I know for a fact that I send it. So I don't understand why the 401?? Oh, and all GET requests work just fine, it's the preflight with OPTIONS that get the 401.. Anyone has any idea about how to solve it?

  • @Per-vh5ex
    @Per-vh5ex ปีที่แล้ว

    First 😄