From ebe60406be5f3f2396ac24c615a9ed52239cd5a3 Mon Sep 17 00:00:00 2001 From: Dessalines 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 e2d0c2ff..7d322580 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 7020b2bd..99ea6151 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 { + 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 { return (

404

+ {this.errCode && ( +

+ {i18n.t('code')}: {i18n.t(this.errCode)} +

+ )}
); }