23 lines
521 B
PHP
23 lines
521 B
PHP
<?php
|
|
|
|
namespace app\middleware;
|
|
|
|
use app\service\JwtService;
|
|
use think\Response;
|
|
|
|
class Cors
|
|
{
|
|
public function handle($request, \Closure $next)
|
|
{
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
|
|
if ($request->method(true) === 'OPTIONS') {
|
|
return Response::create('', 'html', 204);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|