From: Dessalines Date: Tue, 10 Nov 2020 22:45:59 +0000 (-0600) Subject: Forwarding error code to 404 page. X-Git-Url: http://these/git/%7B%60%24%7BarchiveTodayUrl%7D/%7B%60/feeds/inbox/%24%7BUserService.Instance.auth%7D.xml%60%7D?a=commitdiff_plain;h=ebe60406be5f3f2396ac24c615a9ed52239cd5a3;p=lemmy-ui.git Forwarding error code to 404 page. --- 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 { + 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)} +

+ )}
); }