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)
|
||||
{
|
||||
$router = static::getRouterWithRoutes();
|
||||
static::performSubdomainRedirects();
|
||||
|
||||
$domainResult = static::performDomainRouting($uri);
|
||||
if ($domainResult) {
|
||||
return $domainResult;
|
||||
}
|
||||
|
||||
try {
|
||||
$dispatcher = new Routing\Dispatcher($router->getData());
|
||||
return $dispatcher->dispatch($method, $uri);
|
||||
|
@ -62,15 +67,28 @@ class Controller
|
|||
}
|
||||
}
|
||||
|
||||
protected static function performSubdomainRedirects()
|
||||
protected static function performDomainRouting($uri)
|
||||
{
|
||||
$subDomain = Request::getSubDomain();
|
||||
|
||||
switch ($subDomain) {
|
||||
case 'chat':
|
||||
case 'slack':
|
||||
return static::redirect('https://discord.gg/Z3bERWA');
|
||||
}
|
||||
case 'chat':
|
||||
case 'slack':
|
||||
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
|
||||
|
|
|
@ -121,11 +121,6 @@ class Request
|
|||
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 = '/')
|
||||
{
|
||||
return Request::getHttpHeader('Referer', $fallback);
|
||||
|
|
|
@ -29,14 +29,6 @@ class ContentActions extends Actions
|
|||
public static function executeHome(): array
|
||||
{
|
||||
Response::enableHttpCache();
|
||||
|
||||
$serverName = Request::getServerName();
|
||||
if ($serverName === 'lbry.org') {
|
||||
return static::executeOrg();
|
||||
} else if ($serverName === 'lbry.tv') {
|
||||
return static::executeTv();
|
||||
}
|
||||
|
||||
return ['page/home'];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue