正在显示
2 个修改的文件
包含
24 行增加
和
0 行删除
| @@ -44,6 +44,18 @@ class FileController | @@ -44,6 +44,18 @@ class FileController | ||
| 44 | ]; | 44 | ]; |
| 45 | public function __construct() | 45 | public function __construct() |
| 46 | { | 46 | { |
| 47 | + $http_origin = "*"; | ||
| 48 | + if(isset($_SERVER['HTTP_ORIGIN'])){ | ||
| 49 | + $http_origin = $_SERVER['HTTP_ORIGIN']; | ||
| 50 | + } | ||
| 51 | + header("Access-Control-Allow-Origin:".$http_origin); | ||
| 52 | + header('Access-Control-Allow-Methods:POST,GET'); //支持的http 动作 | ||
| 53 | + header('Access-Control-Allow-Credentials: true'); | ||
| 54 | + header('Access-Control-Max-Age: 1000'); | ||
| 55 | + header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization, token'); //响应头 请按照自己需求添加。 | ||
| 56 | + if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') { | ||
| 57 | + exit; | ||
| 58 | + } | ||
| 47 | $this->request = request(); | 59 | $this->request = request(); |
| 48 | $this->param = $this->request->all(); | 60 | $this->param = $this->request->all(); |
| 49 | $this->config = config('filesystems.disks.upload'); | 61 | $this->config = config('filesystems.disks.upload'); |
| @@ -52,6 +52,18 @@ class ImageController extends Controller | @@ -52,6 +52,18 @@ class ImageController extends Controller | ||
| 52 | 52 | ||
| 53 | public function __construct() | 53 | public function __construct() |
| 54 | { | 54 | { |
| 55 | + $http_origin = "*"; | ||
| 56 | + if(isset($_SERVER['HTTP_ORIGIN'])){ | ||
| 57 | + $http_origin = $_SERVER['HTTP_ORIGIN']; | ||
| 58 | + } | ||
| 59 | + header("Access-Control-Allow-Origin:".$http_origin); | ||
| 60 | + header('Access-Control-Allow-Methods:POST,GET'); //支持的http 动作 | ||
| 61 | + header('Access-Control-Allow-Credentials: true'); | ||
| 62 | + header('Access-Control-Max-Age: 1000'); | ||
| 63 | + header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization, token'); //响应头 请按照自己需求添加。 | ||
| 64 | + if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') { | ||
| 65 | + exit; | ||
| 66 | + } | ||
| 55 | $this->request = request(); | 67 | $this->request = request(); |
| 56 | $this->token = $this->request->header('token'); | 68 | $this->token = $this->request->header('token'); |
| 57 | $this->cache = Cache::get($this->token); | 69 | $this->cache = Cache::get($this->token); |
-
请 注册 或 登录 后发表评论