CORS middleware


CORS refers to Cross site resource sharing and how to let the http calls made to your site/ hosting server protect or limit with it. It is a mechanism in which the Access-Control-Allow-Origin
in the response header is set saying the origin of the request is limited to the calls from only those origins. The Origin
needs to be set to the allowed values for the request to be accepted.
When building an app using a http server say like express , one can make use of the cors middleware which actually adds the following in the response headers Access-Control-Allow-Origin: *
for the default configuration. More than one origin can be allowed by passing them as an array like ["http://server1.com", "http://server2.com"] .
Read the MDN's article for more information.