From ebe60406be5f3f2396ac24c615a9ed52239cd5a3 Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Tue, 10 Nov 2020 16:45:59 -0600
Subject: [PATCH] Forwarding error code to 404 page.

---
 src/server/index.tsx               | 4 ++--
 src/shared/components/no-match.tsx | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/server/index.tsx b/src/server/index.tsx
index e2d0c2f..7d32258 100644
--- a/src/server/index.tsx
+++ b/src/server/index.tsx
@@ -46,8 +46,8 @@ server.get('/*', async (req, res) => {
 
   // Redirect to the 404 if there's an API error
   if (routeData[0] && routeData[0].error) {
-    console.log(`Route error: ${routeData[0].error}`);
-    return res.redirect('/404');
+    let errCode = routeData[0].error;
+    return res.redirect(`/404?err=${errCode}`);
   }
 
   let acceptLang = req.headers['accept-language']
diff --git a/src/shared/components/no-match.tsx b/src/shared/components/no-match.tsx
index 7020b2b..99ea615 100644
--- a/src/shared/components/no-match.tsx
+++ b/src/shared/components/no-match.tsx
@@ -1,6 +1,9 @@
 import { Component } from 'inferno';
+import { i18n } from '../i18next';
 
 export class NoMatch extends Component<any, any> {
+  private errCode = new URLSearchParams(this.props.location.search).get('err');
+
   constructor(props: any, context: any) {
     super(props, context);
   }
@@ -9,6 +12,11 @@ export class NoMatch extends Component<any, any> {
     return (
       <div class="container">
         <h1>404</h1>
+        {this.errCode && (
+          <h3>
+            {i18n.t('code')}: {i18n.t(this.errCode)}
+          </h3>
+        )}
       </div>
     );
   }
-- 
2.44.1