Use middleware instead of the noscheme workaround in order to make HTTPS work behind a reverse-proxy

This commit is contained in:
Pierre Rudloff 2017-05-14 21:53:57 +02:00
parent f53fc5ebc1
commit fed425fce3
7 changed files with 70 additions and 238 deletions

View file

@ -30,13 +30,14 @@ class ViewFactory
}
$view = new Smarty(__DIR__.'/../templates/');
if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) {
$request = $request->withUri($request->getUri()->withScheme('https')->withPort(443));
}
$smartyPlugins = new SmartyPlugins($container['router'], $request->getUri());
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
$view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
return $view;
}
}