Use middleware instead of the noscheme workaround in order to make HTTPS work behind a reverse-proxy
This commit is contained in:
parent
f53fc5ebc1
commit
fed425fce3
7 changed files with 70 additions and 238 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue