From 82ada0930b2d9a1c9b2d4e14192e97c7f31a2f14 Mon Sep 17 00:00:00 2001 From: printempw Date: Mon, 17 Oct 2016 09:46:57 +0800 Subject: [PATCH] add option for auto detecting asset url --- app/Providers/AppServiceProvider.php | 10 ++++++---- config/options.php | 5 +++-- resources/views/admin/options.tpl | 11 +++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2441ed07..311361ee 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -18,10 +18,12 @@ class AppServiceProvider extends ServiceProvider // replace HTTP_HOST with site url setted in options to prevent CDN source problems preg_match('/https?:\/\/([^\/]+)\/?.*/', option('site_url'), $host); - // check if host is valid - if (isset($host[1]) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host[1])) { - $this->app['request']->headers->set('host', $host[1]); - }; + if (option('auto_detect_asset_url') == "0") { + // check if host is valid + if (isset($host[1]) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host[1])) { + $this->app['request']->headers->set('host', $host[1]); + }; + } } /** diff --git a/config/options.php b/config/options.php index dcd200c5..ae887d79 100644 --- a/config/options.php +++ b/config/options.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-07-29 11:53:11 * @Last Modified by: printempw - * @Last Modified time: 2016-10-16 20:09:27 + * @Last Modified time: 2016-10-17 09:40:16 */ return [ @@ -36,5 +36,6 @@ return [ 'auto_del_invalid_texture' => '0', 'return_200_when_notfound' => '0', 'cache_expire_time' => '31536000', - 'max_upload_file_size' => '1024' + 'max_upload_file_size' => '1024', + 'auto_detect_asset_url' => '1' ]; diff --git a/resources/views/admin/options.tpl b/resources/views/admin/options.tpl index 74752b8f..d52d64bc 100644 --- a/resources/views/admin/options.tpl +++ b/resources/views/admin/options.tpl @@ -222,6 +222,17 @@ + + 资源地址 + + + + + + + HTTP 响应码