mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
fix domain routing
This commit is contained in:
parent
0b1f00b2f8
commit
18aa28a59b
3 changed files with 24 additions and 19 deletions
|
@ -49,7 +49,12 @@ class Controller
|
||||||
public static function execute($method, $uri)
|
public static function execute($method, $uri)
|
||||||
{
|
{
|
||||||
$router = static::getRouterWithRoutes();
|
$router = static::getRouterWithRoutes();
|
||||||
static::performSubdomainRedirects();
|
|
||||||
|
$domainResult = static::performDomainRouting($uri);
|
||||||
|
if ($domainResult) {
|
||||||
|
return $domainResult;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dispatcher = new Routing\Dispatcher($router->getData());
|
$dispatcher = new Routing\Dispatcher($router->getData());
|
||||||
return $dispatcher->dispatch($method, $uri);
|
return $dispatcher->dispatch($method, $uri);
|
||||||
|
@ -62,7 +67,7 @@ class Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function performSubdomainRedirects()
|
protected static function performDomainRouting($uri)
|
||||||
{
|
{
|
||||||
$subDomain = Request::getSubDomain();
|
$subDomain = Request::getSubDomain();
|
||||||
|
|
||||||
|
@ -71,6 +76,19 @@ class Controller
|
||||||
case 'slack':
|
case 'slack':
|
||||||
return static::redirect('https://discord.gg/Z3bERWA');
|
return static::redirect('https://discord.gg/Z3bERWA');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hostName = $_SERVER['HTTP_HOST'];
|
||||||
|
if ($hostName && in_array($hostName, ['lbry.org', 'lbry.tv'])) {
|
||||||
|
if ($uri !== '/') {
|
||||||
|
return static::redirect('/');
|
||||||
|
}
|
||||||
|
switch($hostName) {
|
||||||
|
case 'lbry.org':
|
||||||
|
return ContentActions::executeOrg();
|
||||||
|
case 'lbry.tv':
|
||||||
|
return ContentActions::executeTv();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function getRouterWithRoutes(): \Routing\RouteCollector
|
protected static function getRouterWithRoutes(): \Routing\RouteCollector
|
||||||
|
|
|
@ -121,11 +121,6 @@ class Request
|
||||||
return static::getHeader('HTTPS') || strtolower(static::getHttpHeader('X_FORWARDED_PROTO')) == 'https';
|
return static::getHeader('HTTPS') || strtolower(static::getHttpHeader('X_FORWARDED_PROTO')) == 'https';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getServerName(): string
|
|
||||||
{
|
|
||||||
return static::getHeader('SERVER_NAME');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getReferrer(string $fallback = '/')
|
public static function getReferrer(string $fallback = '/')
|
||||||
{
|
{
|
||||||
return Request::getHttpHeader('Referer', $fallback);
|
return Request::getHttpHeader('Referer', $fallback);
|
||||||
|
|
|
@ -29,14 +29,6 @@ class ContentActions extends Actions
|
||||||
public static function executeHome(): array
|
public static function executeHome(): array
|
||||||
{
|
{
|
||||||
Response::enableHttpCache();
|
Response::enableHttpCache();
|
||||||
|
|
||||||
$serverName = Request::getServerName();
|
|
||||||
if ($serverName === 'lbry.org') {
|
|
||||||
return static::executeOrg();
|
|
||||||
} else if ($serverName === 'lbry.tv') {
|
|
||||||
return static::executeTv();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['page/home'];
|
return ['page/home'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue