添加安装部署脚本
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
"hyperf/config": "~3.1.0",
|
||||
"hyperf/constants": "~3.1.0",
|
||||
"hyperf/crontab": "~3.1.0",
|
||||
"gokure/hyperf-cors": "^2.1",
|
||||
"hyperf/database-pgsql": "^3.1",
|
||||
"hyperf/db-connection": "~3.1.0",
|
||||
"hyperf/engine": "^2.10",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* CORS 配置
|
||||
*
|
||||
* 前端 Vue (http://server:8080) 跨源访问后端 (http://server:9501) 时必需。
|
||||
* 由于前端走 Bearer token(Authorization header)而非 cookie,
|
||||
* supports_credentials 保持 false,allowed_origins 可使用 '*'。
|
||||
*
|
||||
* 生产环境如要收紧,把 allowed_origins 改成具体域名列表。
|
||||
*/
|
||||
return [
|
||||
// 仅对 /api/* 启用 CORS(前端调用都带此前缀)
|
||||
'paths' => ['api/*'],
|
||||
|
||||
// 允许的方法
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
// 允许的源(通配;若改成 supports_credentials=true,必须列具体域名)
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
// 允许的源(正则匹配,按需启用)
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
// 允许的请求头
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
// 暴露给前端的响应头
|
||||
'exposed_headers' => [],
|
||||
|
||||
// 预检请求缓存时间(秒)
|
||||
'max_age' => 7200,
|
||||
|
||||
// 是否允许携带凭证(cookie / 客户端证书);本项目用 Bearer token,保持 false
|
||||
'supports_credentials' => false,
|
||||
];
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
return [
|
||||
'http' => [
|
||||
\Gokure\HyperfCors\CorsMiddleware::class,
|
||||
\App\Middleware\RequestLogMiddleware::class,
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user