Cross-Origin Resourse Sharing

KATHISH KUMARAN R
YavarTechWorks
Published in
2 min readNov 26, 2022

Hi Friends, In this Blog we are going to learn about the introduction to cross-origin resource sharing.

CORS:

CORS is an HTTP-header based mechanism that allows a server to indicate any origins other than its own from which a browser should permit loading resources.

(Origin is the scheme(Protocol) , Hostname(Domain) and Port of the URL used to access it)

Introduction To CORS:

  • CORS is a mechanism which uses additional http headers to tell the browser whether the specific web app can share the source with another web app. The important point to note here is that both the web app should have different origin, suppose if they have same origin, they can share resources easily, but if they have different origin , then they have to follow cors mechanism.
  • So in real time, cors refers to the situations when a frontend running in a browser has javascript code that communicates with a backend, and the backend is in a diffrent origin than the frontend.Here the cors standard is needed because it allows servers to specify who can access its assets and allow how the assets can be accessed.
  • It is a commonly implemented solution to the same origin policy that is enforced by all browsers.
  • CORS is a browser security feature that restricts cross-origin HTTP requests that are initiated from scripts running in the browser. If your rest API’s resources receive non-simple cross-origin HTTP request, you need to enable cors support.

NOTE:

why you don’t see cors error in postman?

Because postman simply doesn’t care about CORS Headers. So cors is just a browser concept

The cors standard is a client-side standard implemented in the browser. So it is the browser which prevent the call from completing and generates the error message-not the server. POSTMAN does not implement the cors restrictions, which is why you don’t see the same error when making the same call from postman.

Conclusion

In this Blog, we have learned about introduction to cross-origin resource sharing. Hope to see you all in my next blog post, Until then Take Care! Keep Learning!

Thank You For Reading this Blog………

Have a Nice Day……

👋👋👋

--

--