<?php
namespace app\warehouse\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\warehouse\middleware\AllowOriginMiddleware::class
]);


Route::group(function () {
    Route::get('login/captcha', 'Login/captcha');
})->middleware([
    \app\warehouse\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);
});