route.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. use think\facade\Route;
  12. use think\facade\Config;
  13. use think\Response;
  14. use app\http\middleware\AllowOriginMiddleware;
  15. /**
  16. * 无需授权的接口
  17. */
  18. Route::group(function () {
  19. //用户名密码登录
  20. Route::post('login', 'Login/login')->name('AdminLogin');
  21. //后台登录页面数据
  22. Route::get('login/info', 'Login/info');
  23. //下载文件
  24. Route::get('download', 'PublicController/download');
  25. //验证码
  26. Route::get('captcha_pro', 'Login/captcha');
  27. //测试路由
  28. Route::get('index', 'Test/index');
  29. })->middleware(AllowOriginMiddleware::class);
  30. /**
  31. * miss 路由
  32. */
  33. Route::miss(function () {
  34. if (app()->request->isOptions()) {
  35. $header = Config::get('cookie.header');
  36. $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
  37. return Response::create('ok')->code(200)->header($header);
  38. } else
  39. return Response::create()->code(404);
  40. });