diff --git a/js/src/forum/components/ErrorPage.js b/js/src/forum/components/ErrorPage.js
index 6abc6ed4c..fbd7204ad 100644
--- a/js/src/forum/components/ErrorPage.js
+++ b/js/src/forum/components/ErrorPage.js
@@ -1,6 +1,6 @@
import Page from '../../common/components/Page';
-export default class NotAuthenticatedErrorPage extends Page {
+export default class ErrorPage extends Page {
view() {
return (
diff --git a/js/src/forum/routes.js b/js/src/forum/routes.js
index 90204a24e..362ac092a 100644
--- a/js/src/forum/routes.js
+++ b/js/src/forum/routes.js
@@ -25,7 +25,7 @@ export default function (app) {
settings: { path: '/settings', component: SettingsPage },
notifications: { path: '/notifications', component: NotificationsPage },
-
+
error: { path: '/:error', component: ErrorPage },
};
diff --git a/src/Foundation/ErrorHandling/FrontendFormatter.php b/src/Foundation/ErrorHandling/FrontendFormatter.php
index 888390089..ff02962ba 100644
--- a/src/Foundation/ErrorHandling/FrontendFormatter.php
+++ b/src/Foundation/ErrorHandling/FrontendFormatter.php
@@ -10,6 +10,7 @@
namespace Flarum\Foundation\ErrorHandling;
use Flarum\Frontend\Controller;
+use Flarum\Frontend\Frontend;
use Flarum\Http\Content\NotAuthenticated;
use Flarum\Http\Content\NotFound;
use Flarum\Http\Content\PermissionDenied;
@@ -20,38 +21,18 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Symfony\Component\Translation\TranslatorInterface;
/**
- * A formatter for turning caught exceptions into "pretty" HTML error pages.
- *
- * For certain known error types, we display pages with dedicated information
- * relevant to this class of error, e.g. a page with a search form for HTTP 404
- * "Not Found" errors. We look for templates in the `views/error` directory.
- *
- * If no specific template exists, a generic "Something went wrong" page will be
- * displayed, optionally enriched with a more specific error message if found in
- * the translation files.
+ * This formatter will route certain errors to the SPA frontend.
*/
class FrontendFormatter implements HttpFormatter
{
/**
- * @var Container
+ * @var Frontend
*/
- protected $container;
+ protected $frontend;
- /**
- * @var TranslatorInterface
- */
- protected $translator;
-
- /**
- * @var SettingsRepositoryInterface
- */
- protected $settings;
-
- public function __construct(Container $container, TranslatorInterface $translator, SettingsRepositoryInterface $settings)
+ public function __construct(Frontend $frontend)
{
- $this->container = $container;
- $this->translator = $translator;
- $this->settings = $settings;
+ $this->frontend = $frontend;
}
public function format(HandledError $error, Request $request): Response
diff --git a/src/Http/Content/NotAuthenticated.php b/src/Http/Content/NotAuthenticated.php
index a40078c7b..66faa1ff1 100644
--- a/src/Http/Content/NotAuthenticated.php
+++ b/src/Http/Content/NotAuthenticated.php
@@ -17,7 +17,7 @@ class NotAuthenticated
public function __invoke(Document $document, Request $request)
{
$document->title = 'Not Authenticated';
- $document->payload['errorCode'] = 103;
+ $document->payload['errorCode'] = 401;
return $document;
}
diff --git a/src/Http/HttpServiceProvider.php b/src/Http/HttpServiceProvider.php
index 1947efe28..a14c88e18 100644
--- a/src/Http/HttpServiceProvider.php
+++ b/src/Http/HttpServiceProvider.php
@@ -20,6 +20,7 @@ use Flarum\Foundation\ErrorHandling\FrontendFormatter;
use Flarum\Foundation\ErrorHandling\Registry;
use Flarum\Foundation\ErrorHandling\Reporter;
use Flarum\Foundation\ErrorHandling\WhoopsFormatter;
+use Flarum\Frontend\Frontend;
use Flarum\Http\Exception\RouteNotFoundException;
use Flarum\User\Exception\NotAuthenticatedException;
use Flarum\User\Exception\PermissionDeniedException;
@@ -88,6 +89,12 @@ class HttpServiceProvider extends AbstractServiceProvider
$this->container->make('flarum.http.frontend_exceptions')
);
});
+
+ $this->container->when(FrontendFormatter::class)
+ ->needs(Frontend::class)
+ ->give(function () {
+ return $this->container->make('flarum.frontend.forum');
+ });
}
/**