Access-Control-Allow-Origin Response Header Explained (CORS) - HTTP/Web Tutorial

preview_player
Показать описание
In this video tutorial I'll be explaining what the "Access-Control-Allow-Origin" HTTP Response Header is used for, and how to resolve one of the most common errors you'll get when using AJAX or Fetch.

Support me on Patreon:

For your reference, check this out:

Follow me on Twitter @dcodeyt!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

After watching this back I realised that I forgot to mention at the end that my example is *purely* trivial, realistically you would instead have some sort of list of white listed origins, and then if your request has one of those, then allow it to access the resource.

dcode-software
Автор

Thank you man!!
I had already read A LOT of articles, and understood NOTHING, until I landed here, and you enlighted my path. As usual, a great example is worth much more than thousands of words

robertocantu
Автор

This guy can magically read minds. He uploads a video just when I need to search something but I feel lazy to do so!

ahora
Автор

you are a life saver... i have been struggling with cors error for a long time and was finding hard workarounds to get past it.... but today after seeing your video I got how cors works and found the easiest and feasible way to kickout this issue....❤️❤️❤️🔥🔥🔥

alexachadan
Автор

dud, I just wanna say: thank you so much in all ways possible.
Your explanation allowed me to understand CORS once and for all after a lot of years, therefore to give solution to a stuff I put in "Will check this later" years ago.
Thank you, thank you

giquo
Автор

finally a video telling me literally put *) to fix this issue, thank god, liked and subscribed .

AkiZukiLenn
Автор

Better than every article I've found!

Rompack
Автор

@dcode: THANKS A LOT man !!! The hint with not using the absolute URL worked for me ! :)

zauche
Автор

Great video! Helped me solve a problem I've been grappling with for hours

MegaNightdude
Автор

This here saved me a lot of headache. Thanks a lot

u
Автор

Just Perfect. You really helped me after weeks of research i just got my stuff work👍🏻

TreudtLP
Автор

Exactly what I needed
Please tell use of mode : no-cors, core, etc

_.sunnyraj._
Автор

What if the api is on the internet? I’ve been trying to type on my js mode no corse and access control allow origin * but nothing worked, so I saved it as a separate file but still...

riccardoconsolandi
Автор

Thank you very much.
It was very useful.

sharifi
Автор

thanks man, you just saved my head from bursting ! :D

YeasinRahaman
Автор

great accent mate, love from melbourne!

theITvideos
Автор

I wish people would use an external api instead of php, so those of us geared towards express[MERN] didn't have to run both express and apache (phpMyAdmin gives 2 instances of mysql, I know how to fix the config for this, it's fine, but the point remains)

It might help explain when we are using Ajax to consume something,
And when we are using Ajax on our own server.
Client/server, kind of blurred line sometimes, not really, but the point remains.

You all are still awesome, I'll still install xampp for the concepts sake (only to uninstall the server I'm not running any prod apps on after)

Do people normally put up express apps and apache apps on production at the same time?

I have express apps in prod
but none in apache / *AMP

I wonder what the netstat output for that would look like. Both in dev mode, and in prod.

netstat -a -n -p tcp -b

FordExplorer-rmew
Автор

what kind of headers would u set if u were uploading & downloading a zip file that contained source code?

Cdswjp
Автор

Hii if the backend is completely different, how do we solve it. Basically I get a 405 error. I'm able to see the response headers but not the response body. I'm trying to access uipath api endpoint for folders. However I m trying to pass the access token, using multiple fetch, but I run into the CoRs error n 405 status code. Could you please shed some light on this ??

gauridangui
Автор

What is the http origin for android app? I really didn't find any way to get to know the special origin of Android Apps.

chanmyaemaung