Google News
logo
Ionic - Interview Questions
What is CORS? How would you deal with it?
CORS stands for cross-origin resource sharing. It is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, have permission to access selected resources from a different origin.
 
A web application makes a cross-origin request for a resource like an image or a font outside of the origin, and CORS manages these cross-origin requests. The CORS standard is necessary because it allows servers to specify who can access its assets and how the assets can be accessed.
 
For security reasons, the browser restricts cross-origin requests initiated within scripts. The CORS needs to be handled on the server. When responding to HTTP requests in your server app, you can add the CORS response headers to specify that the client app can access a resource or not. If the CORS is not implemented on the server, then there is a native plugin available that performs HTTP requests in the native layer, which bypasses CORS. Thus, external services can properly handle cross-origin requests.
Advertisement