Skip to content

Commit

Permalink
[fix] Error Message exposing
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Aug 1, 2024
1 parent bf761fe commit 5acf0bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 9 additions & 3 deletions components/NotFoundCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { ErrorProps } from 'next/error';
import { FC } from 'react';

import { i18n } from '../models/Translation';

export const NotFoundCard: FC = () =>
export const NotFoundCard: FC<ErrorProps> = ({ title }) =>
i18n.currentLanguage.startsWith('zh') ? (
// @ts-ignore
<script src="//cdn.dnpw.org/404/v1.min.js" jumptarget="/" jumptime="-1" />
<script
src="//cdn.dnpw.org/404/v1.min.js"
// @ts-ignore
jumptarget="/"
jumptime="-1"
error={title}
/>
) : (
<iframe
className="w-100 vh-100 border-0"
Expand Down
6 changes: 3 additions & 3 deletions pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Error from 'next/error';
import { NotFoundCard } from '../components/NotFoundCard';
import { i18n } from '../models/Translation';

const CustomErrorComponent: NextPage<ErrorProps> = ({ statusCode }) => (
const CustomErrorComponent: NextPage<ErrorProps> = props => (
<>
<h1 className="text-center">{statusCode}</h1>
<Error {...props} />

<NotFoundCard />
<NotFoundCard {...props} />
</>
);
const enableSentry =
Expand Down
4 changes: 4 additions & 0 deletions styles/globals.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ article {
max-width: 100%;
}
}
// custom 404 page (Global edition)
div:has(.next-error-h1) {
height: auto !important;
}
// custom 404 page (Chinese edition)
.wrap_404 .wrap_right {
width: 80vw !important;
Expand Down

1 comment on commit 5acf0bd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for next-bootstrap-ts ready!

✅ Preview
https://next-bootstrap-3pd4i8e5k-stevending1sts-projects.vercel.app

Built with commit 5acf0bd.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.