Web Security

What Is CORS (Cross-Origin Resource Sharing)?

A browser security mechanism that controls which domains can make requests to your web application. By default, browsers block cross-origin requests (requests from a different domain). CORS headers tell the browser which origins, methods, and headers are allowed.

In Laravel Applications

Configure CORS in config/cors.php. The most dangerous misconfiguration is setting allowed_origins to ["*"] (any domain) on authenticated endpoints. This allows any website to make requests to your API on behalf of your users.

Example

With Access-Control-Allow-Origin: *, a malicious website can make AJAX requests to your Laravel API endpoints, reading data and performing actions as the authenticated user.

Related Terms

Monitor Your Laravel Application's Security

StackShield continuously checks your Laravel application from the outside, catching security issues before attackers find them.

Start Free Trial