// in order to remove the jwt on the browser. Necessary for wrong jwts
let site: GetSiteResponse | undefined = undefined;
let routeData: any[] = [];
+ let errorPageData: ErrorPageData | undefined;
try {
let try_site: any = await client.getSite(getSiteForm);
if (try_site.error == "not_logged_in") {
}
}
} catch (error) {
- routeData = getErrorRouteData(error, site);
+ errorPageData = getErrorRouteData(error, site);
}
// Redirect to the 404 if there's an API error
if (error === "instance_is_private") {
return res.redirect(`/signup`);
} else {
- routeData = getErrorRouteData(error, site);
+ errorPageData = getErrorRouteData(error, site);
}
}
path,
site_res: site,
routeData,
+ errorPageData,
};
const wrapper = (
}
function getErrorRouteData(error: string, site?: GetSiteResponse) {
- const errorPageData: ErrorPageData = { type: "error" };
+ const errorPageData: ErrorPageData = {};
// Exact error should only be seen in a development environment. Users
// in production will get a more generic message.
errorPageData.adminMatrixIds = adminMatrixIds;
}
- return [errorPageData];
+ return errorPageData;
}
async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) {
import { Component } from "inferno";
import { Link } from "inferno-router";
import { IsoDataOptionalSite } from "shared/interfaces";
-import { ErrorPageData, setIsoData } from "../../utils";
+import { setIsoData } from "../../utils";
export class ErrorPage extends Component<any, any> {
private isoData: IsoDataOptionalSite = setIsoData(this.context);
}
render() {
- const errorPageData = this.getErrorPageData();
+ const { errorPageData } = this.isoData;
return (
<div className="container-lg text-center">
</div>
);
}
-
- private getErrorPageData() {
- const errorPageData = this.isoData.routeData[0] as
- | ErrorPageData
- | undefined;
- if (errorPageData?.type === "error") {
- return errorPageData;
- }
-
- return undefined;
- }
}
import { Component } from "inferno";
-import { ErrorPageData, setIsoData } from "../../utils";
+import { setIsoData } from "../../utils";
import { ErrorPage } from "../app/error-page";
class ErrorGuard extends Component<any, any> {
}
render() {
- const errorPageData = this.isoData.routeData[0] as
- | ErrorPageData
- | undefined;
+ const errorPageData = this.isoData.errorPageData;
const siteRes = this.isoData.site_res;
- if (errorPageData?.type === "error" || !siteRes) {
+ if (errorPageData || !siteRes) {
return <ErrorPage />;
} else {
return this.props.children;
import { CommentView, GetSiteResponse, LemmyHttp } from "lemmy-js-client";
import type { ParsedQs } from "qs";
+import { ErrorPageData } from "./utils";
/**
* This contains serialized data, it needs to be deserialized before use.
path: string;
routeData: any[];
site_res: GetSiteResponse;
+ errorPageData?: ErrorPageData;
}
export type IsoDataOptionalSite = Partial<IsoData> &
| "gray-dark";
export interface ErrorPageData {
- type: "error";
error?: string;
adminMatrixIds?: string[];
}