You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
<?php
|
|
namespace app\home\middleware;
|
|
use Closure;
|
|
use think\middleware\AllowCrossDomain;
|
|
|
|
class CorsMiddleware extends AllowCrossDomain
|
|
{
|
|
|
|
protected $header = [
|
|
'Access-Control-Allow-Credentials' => 'true',
|
|
'Access-Control-Max-Age' => 1800,
|
|
'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
|
|
'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With,Token,Language',
|
|
];
|
|
public function handle($request, Closure $next, ?array $header = [])
|
|
{
|
|
header('Access-Control-Allow-Origin: *' );
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type, Authorization,Accpet,Token,Language');
|
|
header('Access-Control-Max-Age: 86400');
|
|
header('Access-Control-Allow-Credentials: true');
|
|
return parent::handle($request, $next, $header); // TODO: Change the autogenerated stub
|
|
}
|
|
|
|
}
|
|
|
|
|