12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\admin\route;
- use app\admin\middleware\AllowOriginMiddleware;
- use app\admin\middleware\SeretKeyMiddleware;
- use think\facade\Config;
- use think\facade\Route;
- use think\Response;
- /**
- * 无需授权的接口
- */
- Route::group(function () {
- //后台管理员登录
- Route::rule('login/login', 'Login/index');
- //验证码
- Route::rule('index', 'Index/index');
- })->middleware([
- \app\admin\middleware\AllowOriginMiddleware::class
- ]);
- Route::group(function () {
- Route::get('login/captcha', 'Login/captcha');
- })->middleware([
- \app\admin\middleware\AllowOriginMiddleware::class
- ]);
- /**
- * miss 路由
- */
- Route::miss(function () {
- if (app()->request->isOptions()) {
- $header = Config::get('cookie.header');
- $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
- return Response::create('ok')->code(200)->header($header);
- } else
- return Response::create()->code(404);
- });
|