index.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // [ 应用入口文件 ]
  12. namespace think;
  13. require __DIR__ . '/../vendor/autoload.php';
  14. // ===================== 万能跨域=====================
  15. header('Access-Control-Allow-Origin: *');
  16. header('Access-Control-Allow-Methods: *');
  17. header('Access-Control-Allow-Headers: *'); // ✅ 允许所有请求头(lang、sessionid、token 全部通吃)
  18. header('Access-Control-Allow-Credentials: true');
  19. header('Access-Control-Max-Age: 86400');
  20. if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  21. http_response_code(200);
  22. exit();
  23. }
  24. // ===================== 跨域结束 =====================
  25. // 定义配置文件目录和应用目录同级
  26. define('CONF_PATH', __DIR__.'/../config/');
  27. define('PUBLIC_PATH', __DIR__.'/');
  28. define('PACKAGE_PATH', __DIR__.'/unpackage/');
  29. // 执行HTTP应用并响应
  30. $http = (new App())->http;
  31. $response = $http->run();
  32. $response->send();
  33. $http->end($response);