Use relative paths on debug error page
This commit is contained in:
parent
9a27e7764a
commit
f2be3a7e5b
3 changed files with 17 additions and 2 deletions
|
@ -37,6 +37,8 @@ class App extends \Slim\App
|
||||||
/** @var Container $container */
|
/** @var Container $container */
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
|
|
||||||
|
$container['root_path'] = $this->getRootPath();
|
||||||
|
|
||||||
// Config.
|
// Config.
|
||||||
$container['config'] = ConfigFactory::create($container);
|
$container['config'] = ConfigFactory::create($container);
|
||||||
|
|
||||||
|
@ -110,4 +112,17 @@ class App extends \Slim\App
|
||||||
[$jsonController, 'json']
|
[$jsonController, 'json']
|
||||||
)->setName('json');
|
)->setName('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
private function getRootPath(): ?string
|
||||||
|
{
|
||||||
|
// realpath() can return false but we prefer using null.
|
||||||
|
if ($rootPath = realpath(__DIR__ . '/../')) {
|
||||||
|
return $rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ class FrontController extends BaseController
|
||||||
$response = $cspMiddleware->applyHeader($response);
|
$response = $cspMiddleware->applyHeader($response);
|
||||||
|
|
||||||
if ($this->config->debug) {
|
if ($this->config->debug) {
|
||||||
$renderer = new HtmlErrorRenderer(true);
|
$renderer = new HtmlErrorRenderer(true, null, null, $this->container->get('root_path'));
|
||||||
$exception = $renderer->render($error);
|
$exception = $renderer->render($error);
|
||||||
|
|
||||||
$response->getBody()->write($exception->getAsString());
|
$response->getBody()->write($exception->getAsString());
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ErrorHandler
|
||||||
|
|
||||||
if (class_exists(HtmlErrorRenderer::class)) {
|
if (class_exists(HtmlErrorRenderer::class)) {
|
||||||
// If dev dependencies are loaded, we can use symfony/error-handler.
|
// If dev dependencies are loaded, we can use symfony/error-handler.
|
||||||
$renderer = new HtmlErrorRenderer(true);
|
$renderer = new HtmlErrorRenderer(true, null, null, dirname(__DIR__));
|
||||||
$exception = $renderer->render($e);
|
$exception = $renderer->render($e);
|
||||||
|
|
||||||
http_response_code($exception->getStatusCode());
|
http_response_code($exception->getStatusCode());
|
||||||
|
|
Loading…
Reference in a new issue