Category: Laravel, api, javascript

While building API with micro-service based application, we often face an error as — ‘https://localhost:8000’ has been blocked by CORS policy: No Access-Control-Allow-Origin header is present on the requested resource. This story will assist you to fix this issue in Lumen application with the help of Laravel-cors package step by step.

allowed_origins_patterns: Thisoptionmatches the request origin with patterns allowed_headers: This specifies to set the Access-Control-Allow-Headers, which is used in response to a preflight request which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request.

max_age: This option is used to set the Access-Control-Max-Age response header.

The Access-Control-Allow-Credentials response header tells browsers whether to expose the response to frontend JavaScript code when the request's credentials mode (Request.credentials) is included.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners