- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务 - 将短信验证码从6位改为4位,优化用户体验 - 添加聚水潭商品按时间范围同步功能,支持分页拉取 - 增强Cron任务异常处理,添加错误日志记录 - 修复系统附件服务中图片路径处理逻辑 - 更新阿里云SDK相关组件至最新版本 - 添加think-trace调试扩展,便于问题排查 - 优化跨域中间件,使用str_contains替代strpos
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\http\middleware;
|
||
|
||
|
||
use app\Request;
|
||
use crmeb\interfaces\MiddlewareInterface;
|
||
use think\facade\Config;
|
||
use think\Response;
|
||
|
||
/**
|
||
* 跨域中间件
|
||
* Class AllowOriginMiddleware
|
||
* @package app\http\middleware
|
||
*/
|
||
class AllowOriginMiddleware implements MiddlewareInterface
|
||
{
|
||
|
||
/**
|
||
* 允许跨域的域名
|
||
* @var string
|
||
*/
|
||
protected $cookieDomain;
|
||
|
||
/**
|
||
* @param Request $request
|
||
* @param \Closure $next
|
||
* @return Response
|
||
*/
|
||
public function handle(Request $request, \Closure $next)
|
||
{
|
||
$this->cookieDomain = Config::get('cookie.domain', '');
|
||
$header = Config::get('cookie.header');
|
||
$origin = $request->header('origin');
|
||
|
||
if ($origin && ('' === $this->cookieDomain || str_contains($origin, $this->cookieDomain))) {
|
||
$header['Access-Control-Allow-Origin'] = $origin;
|
||
}
|
||
if ($request->method(true) == 'OPTIONS') {
|
||
$response = Response::create('ok')->code(200)->header($header);
|
||
} else {
|
||
$response = $next($request)->header($header);
|
||
}
|
||
$request->filter(['strip_tags', 'addslashes', 'trim']);
|
||
return $response;
|
||
}
|
||
}
|