Cross.php 733 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace app\http\middleware;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. class Cross
  6. {
  7. public function handle($request, \Closure $next)
  8. {
  9. header('Access-Control-Allow-Origin: *');
  10. header("Access-Control-Allow-Headers: Authorization, Sec-Fetch-Mode, DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, If-Match, If-None-Match, If-Unmodified-Since, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept-Language, Origin, Accept-Encoding");
  11. header('Access-Control-Allow-Methods: GET, POST');
  12. header('Access-Control-Max-Age: 1728000');
  13. if (strtoupper($request->method()) == "OPTIONS") {
  14. return response();
  15. }
  16. return $next($request);
  17. }
  18. }