1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- declare (strict_types = 1);
- namespace app\middleware;
- use Closure;
- use think\Config;
- use think\Request;
- use think\Response;
- class AllowCrossDomain
- {
- protected $cookieDomain;
-
- 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-Origin' =>'*'
-
- ];
-
- public function __construct(Config $config)
- {
-
- }
-
- public function handle($request, Closure $next, ?array $header = [])
- {
- $header = !empty($header) ? array_merge($this->header, $header) : $this->header;
-
-
-
-
-
-
-
-
- return $next($request)->header($header);
- }
- }
|