fix url() function when using CDN

This commit is contained in:
printempw 2016-09-27 22:15:51 +08:00
parent 5304062b40
commit 446149c9ef

View File

@ -15,7 +15,13 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
// 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]);
};
}
/**