CORS express.js tutorial | Cross-Origin Resource Sharing in Node

preview_player
Показать описание

In this video we cover what CORS (Cross Origin Resource Sharing), why you need and how you can customize your express server's behaviour. We cover how to use CORS in express and how to enable OPTIONS requests to allow CORS preflights.

We cover the complete CORS setup from scratch and build a custom CORS middleware that returns Access-Control-Allow-Origin HTTP headers.

00:00 Introduction
00:20 What is CORS (Cross Origin Resource Sharing)?
01:03 What is an origin?
02:05 Where is CORS used?
02:42 How CORS works
05:18 CORS and Postman
06:18 Relaxing security requirements with CORS
06:54 CORS preflights
12:17 Custom CORS configuration in express
13:49 CORS middleware in express
14:49 Allowing multiple CORS origins
15:53 CORS Origin headers
17:24 OPTIONS requests in express for CORS
20:00 Conclusion
Рекомендации по теме
Комментарии
Автор

What do you think about this video?
Please let me know in the comments below.

jgoebel
Автор

Thank you for explaining it in such detail. I looked for many videos for CORS explanation and yours might be one of the best ones.

BB-boiy
Автор

Finally someone explains it properly! Thanks!!

quofintech
Автор

I have watched many videos, more than helping me understand the concept, it confuses me a lot. But your videos are clear to the point! Keep making great content! 👍

GomathiSundaram
Автор

5:44 - Wow, I was seriously telling me self this CORS is not protecting the server and then you mentioned about POSTMAN and changing the header... Excellent explanation on the topic on the theory of CORS.

sto
Автор

Best explanation, was using CORS for a year, but today got to know the exact working of it behind the scene.

shubhamagarwal
Автор

Thank you so much for this video. I now have a better understanding of CORS.

successezeh
Автор

Dude I was with that bug for 2 days, you saved my life haha thanks :D

yonathanjaramillo
Автор

This is a great job you deserve more viewers.

earthycoin
Автор

This has greatly helped me understand CORS. Please keep making videos!

danielvanpelt
Автор

Great video as always! Keep up the good work!

ParkTheShark
Автор

Thank you so much. I like your explanation. It is very clear to understand.

beratdinckan
Автор

Another great video, thanks man. I second the other commenters suggestion of creating a PERN stack application, but in terms of a more scalable / prod level app, instead of a simple app like every other video. Something that would actually be used in a more serious level. Also hoping to see maybe some videos on docker and kubernets in the future.

tongobongo
Автор

You are awesome. Really thank you very much

maliqattan
Автор

I have a React js (axios) application on the client side and Node js (express) on the backend. I use aws iis ec2 as my hosting server. All works fine both in development and production, except when I connect to Veepn Chrome (from production) then my token header is not found. I have no idea what's happening.

BobbyAlimardani
Автор

the video image is too poor, you need to fix it more

trangphamthi