12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace app\api\route;
- use app\api\middleware\AllowOriginMiddleware;
- use app\api\middleware\SeretKeyMiddleware;
- use think\facade\Config;
- use think\facade\Route;
- use think\Response;
- /**
- * 无需授权的接口
- */
- Route::group(function () {
- Route::rule('index', 'Index/index');
- })->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);
- });
|