2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2023-05-02 03:43:32 +12:00
|
|
|
use Appwrite\Utopia\Request;
|
2022-05-27 01:23:49 +12:00
|
|
|
use Appwrite\Utopia\Response;
|
2024-09-21 04:30:05 +12:00
|
|
|
use Utopia\App;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2024-09-21 04:30:05 +12:00
|
|
|
App::init()
|
2022-11-23 10:14:38 +13:00
|
|
|
->groups(['web'])
|
|
|
|
->inject('request')
|
|
|
|
->inject('response')
|
|
|
|
->action(function (Request $request, Response $response) {
|
|
|
|
$response
|
|
|
|
->addHeader('X-Frame-Options', 'SAMEORIGIN') // Avoid console and homepage from showing in iframes
|
|
|
|
->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url=' . \urlencode($request->getURI()))
|
|
|
|
->addHeader('X-UA-Compatible', 'IE=Edge') // Deny IE browsers from going into quirks mode
|
|
|
|
;
|
|
|
|
});
|
|
|
|
|
2024-09-21 04:30:05 +12:00
|
|
|
App::get('/')
|
2023-06-03 09:22:28 +12:00
|
|
|
->alias('auth/*')
|
2022-10-31 21:53:36 +13:00
|
|
|
->alias('/invite')
|
|
|
|
->alias('/login')
|
2024-02-24 00:13:22 +13:00
|
|
|
->alias('/mfa')
|
2023-07-11 09:20:24 +12:00
|
|
|
->alias('/card/*')
|
2022-10-31 21:53:36 +13:00
|
|
|
->alias('/recover')
|
2023-06-03 09:22:28 +12:00
|
|
|
->alias('/register/*')
|
2022-10-12 03:36:39 +13:00
|
|
|
->groups(['web'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'home')
|
2023-05-02 03:43:32 +12:00
|
|
|
->inject('request')
|
2022-06-22 22:51:49 +12:00
|
|
|
->inject('response')
|
2023-09-26 02:05:51 +13:00
|
|
|
->action(function (Request $request, Response $response) {
|
2024-07-18 05:24:52 +12:00
|
|
|
$url = parse_url($request->getURI());
|
|
|
|
$target = "/console{$url['path']}";
|
2024-09-04 12:18:59 +12:00
|
|
|
$params = $request->getParams();
|
|
|
|
if (!empty($params)) {
|
|
|
|
$target .= "?" . \http_build_query($params);
|
2023-05-02 03:43:32 +12:00
|
|
|
}
|
2024-07-18 05:24:52 +12:00
|
|
|
if ($url['fragment'] ?? false) {
|
|
|
|
$target .= "#{$url['fragment']}";
|
|
|
|
}
|
|
|
|
$response->redirect($target);
|
2022-10-31 21:53:36 +13:00
|
|
|
});
|