fix(ui): show real status code on error page
Unified · Split
| @@ -5,12 +5,11 @@ import { buttonVariants } from "@/components/ui/button"; · 4 unmodified lines | |||
| 5 | import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling"; | 5 | import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling"; |
| 6 | 6 | ||
| 7 | interface Props { | 7 | interface Props { |
| 8 | statusCode: number; | 8 | statusCode?: number; |
| 9 | error?: Error; | ||
| 10 | } | 9 | } |
| 11 | 10 | ||
| 12 | export default function Custom404({ statusCode, error }: Props) { | 11 | export default function ErrorPage({ statusCode }: Props) { |
| 13 | const displayStatusCode = statusCode || 400; | 12 | const displayStatusCode = statusCode || 500; |
| 14 | const { config: whitelabeling } = useWhitelabelingPublic(); | 13 | const { config: whitelabeling } = useWhitelabelingPublic(); |
| 15 | const appName = whitelabeling?.appName || "Dokploy"; | 14 | const appName = whitelabeling?.appName || "Dokploy"; |
| 16 | const logoUrl = whitelabeling?.logoUrl || undefined; | 15 | const logoUrl = whitelabeling?.logoUrl || undefined; |
| @@ -45,12 +44,6 @@ export default function Custom404({ statusCode, error }: Props) { · 28 unmodified lines | |||
| 45 | {errorDescription} | 44 | {errorDescription} |
| 46 | </p> | 45 | </p> |
| 47 | )} | 46 | )} |
| 48 | {error && ( | ||
| 49 | <div className="mt-3 text-red-500"> | ||
| 50 | <p>{error.message}</p> | ||
| 51 | </div> | ||
| 52 | )} | ||
| 53 | |||
| 54 | <div className="mt-5 flex flex-col justify-center items-center gap-2 sm:flex-row sm:gap-3"> | 47 | <div className="mt-5 flex flex-col justify-center items-center gap-2 sm:flex-row sm:gap-3"> |
| 55 | <Link | 48 | <Link |
| 56 | href="/dashboard/home" | 49 | href="/dashboard/home" |
| @@ -101,8 +94,7 @@ export default function Custom404({ statusCode, error }: Props) { · 44 unmodified lines | |||
| 101 | ); | 94 | ); |
| 102 | } | 95 | } |
| 103 | 96 | ||
| 104 | // @ts-ignore | 97 | ErrorPage.getInitialProps = ({ res, err }: NextPageContext) => { |
| 105 | Error.getInitialProps = ({ res, err }: NextPageContext) => { | 98 | const statusCode = res ? res.statusCode : err ? (err.statusCode ?? 500) : 404; |
| 106 | const statusCode = res ? res.statusCode : err ? err.statusCode : 404; | 99 | return { statusCode }; |
| 107 | return { statusCode, error: err }; | ||
| 108 | }; | 100 | }; |