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.