mirror of https://github.com/Rudloff/alltube.git
Review adjustments
This commit is contained in:
parent
d3d9681b5f
commit
086fb93a3a
|
@ -76,7 +76,7 @@ You will need PHP 7.2 (or higher) and the following PHP modules:
|
|||
|
||||
## Web server configuration
|
||||
|
||||
If you want to serve the application under a basepath and/or with a different internal than external port (scenario: nginx->docker setup) alltube supports the following headers:
|
||||
If you want to serve the application under a basepath and/or with a different internal than external port (scenario: nginx->docker setup) Alltube supports the following headers:
|
||||
|
||||
* X-Forwarded-Port (example: `5555`)
|
||||
* X-Forwarded-Path (example: `/alltube`)
|
||||
|
|
|
@ -39,13 +39,13 @@ class ViewFactory
|
|||
$uri = $uri->withScheme('https')->withPort(443);
|
||||
}
|
||||
|
||||
$port = ViewFactory::extractHeader($request, 'X-Forwarded-Port');
|
||||
if (!is_null($port)) {
|
||||
$port = current($request->getHeader('X-Forwarded-Port'));
|
||||
if ($port) {
|
||||
$uri = $uri->withPort(intVal($port));
|
||||
}
|
||||
|
||||
$path = ViewFactory::extractHeader($request, 'X-Forwarded-Path');
|
||||
if (!is_null($path)) {
|
||||
$path = current($request->getHeader('X-Forwarded-Path'));
|
||||
if ($path) {
|
||||
$uri = $uri->withBasePath($path);
|
||||
}
|
||||
|
||||
|
@ -62,39 +62,4 @@ class ViewFactory
|
|||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the header name from the given request.
|
||||
* Multiple headers with the same name are not supported; the first one would be returned in this case.
|
||||
*
|
||||
* @param Request|null $request PSR-7 request
|
||||
* @param string $headerName name of the header
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function extractHeader(Request $request = null, string $headerName)
|
||||
{
|
||||
if (is_null($request)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$header = $request->getHeader($headerName);
|
||||
$count = sizeof($header);
|
||||
if ($count < 1) {
|
||||
return null;
|
||||
}
|
||||
return $header[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the basepath as specified via 'X-Forwarded-Path' from the request if present.
|
||||
*
|
||||
* @param Request|null $request PSR-7 request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getBasePath(Request $request = null)
|
||||
{
|
||||
return ViewFactory::extractHeader($request, 'X-Forwarded-Path');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ try {
|
|||
$container['notAllowedHandler'] = [$frontController, 'notAllowed'];
|
||||
|
||||
// Routes.
|
||||
$basePath = ViewFactory::getBasepath($container->get('request'));
|
||||
$basePath = current($container->get('request')->getHeader('X-Forwarded-Path'));
|
||||
$app->get(
|
||||
$basePath . '/',
|
||||
[$frontController, 'index']
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<meta name="twitter:description" content="{$description|escape}"/>
|
||||
<meta property="og:description" content="{$description|escape}"/>
|
||||
{/if}
|
||||
<link rel="stylesheet" href="{base_url}/css/fonts.css"/>
|
||||
<link rel="stylesheet" href="{base_url}/vendor/webfontkit/open-sans/open-sans.css"/>
|
||||
<link rel="stylesheet" href="{base_url}/css/style.css"/>
|
||||
<title>{$config->appName}{if isset($title)} - {$title|escape}{/if}</title>
|
||||
<link rel="canonical" href="{$canonical}"/>
|
||||
|
|
Loading…
Reference in New Issue