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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners