PHP code example of componenta / http-cors-middleware
1. Go to this page and download the library: Download componenta/http-cors-middleware library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
componenta / http-cors-middleware example snippets
use Componenta\Http\Middleware\Cors\CorsConfiguration;
use Componenta\Http\Middleware\Cors\CorsMiddleware;
$middleware = new CorsMiddleware(
config: new CorsConfiguration(
allowedOrigins: ['https://example.com'],
allowedMethods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
allowCredentials: true,
),
responseFactory: $responseFactory,
);