21 lines
1.1 KiB
PHP
21 lines
1.1 KiB
PHP
<?php
|
|
header('Content-Type: text/html;charset=utf-8');
|
|
header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
|
|
header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE,PUT'); // 允许请求的类型
|
|
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
|
|
header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin,X-Csrf,Authorization,x-app-client-id,x-app-platform,x-app-version,x-csrf,x-mch-id,x-requested-time,x-requested-with,Language,access_token'); // 设置允许自定义请求头的字段
|
|
// comment out the following two lines when deployed to production
|
|
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
|
|
echo json_encode(['code'=>'0','msg'=>'ok']);
|
|
exit();
|
|
}
|
|
// comment out the following two lines when deployed to production
|
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
|
defined('YII_ENV') or define('YII_ENV', 'dev');
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
|
|
|
|
$config = require __DIR__ . '/../config/web.php';
|
|
(new yii\web\Application($config))->run();
|