Skip to main content

Posts

Showing posts with the label Laravel

Cross-Origin Resource Sharing – Laravel Framework

The frontend JavaScript code for a web application served from a domain uses Http Request to make a request for the API in the backend domain. For security reasons, browsers restrict cross-origin HTTP requests initiated within scripts. So how do we resolve it? The main cause  is because, Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin. A web application makes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, and port) than its own origin. Here is the Solution for this issue: A web application using those APIs can only request HTTP resources from the same origin the application was loaded from, unless the response from the other origin includes the right CORS headers. The CORS mechanism supports secure cross-origin r...