-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
962 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ErrorProps } from 'next/error'; | ||
import { FC } from 'react'; | ||
|
||
import { i18n } from '../models/Translation'; | ||
|
||
export const NotFoundCard: FC<ErrorProps> = ({ title }) => | ||
i18n.currentLanguage.startsWith('zh') ? ( | ||
<script | ||
src="//cdn.dnpw.org/404/v1.min.js" | ||
// @ts-ignore | ||
jumptarget="/" | ||
jumptime="-1" | ||
error={title} | ||
/> | ||
) : ( | ||
<iframe | ||
className="w-100 vh-100 border-0" | ||
src="https://notfound-static.fwebservices.be/en/404?key=66abb751ed312" | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
import { parseCookie, parseLanguageHeader } from 'mobx-i18n'; | ||
import type { NextPage } from 'next'; | ||
import type { ErrorProps } from 'next/error'; | ||
import Error from 'next/error'; | ||
|
||
const CustomErrorComponent: NextPage<ErrorProps> = ({ statusCode }) => ( | ||
<Error statusCode={statusCode} /> | ||
import { NotFoundCard } from '../components/NotFoundCard'; | ||
import { i18n } from '../models/Translation'; | ||
|
||
const CustomErrorComponent: NextPage<ErrorProps> = props => ( | ||
<> | ||
<Error {...props} /> | ||
|
||
<NotFoundCard {...props} /> | ||
</> | ||
); | ||
const enableSentry = | ||
process.env.NODE_ENV === 'development' || !process.env.SENTRY_AUTH_TOKEN; | ||
|
||
CustomErrorComponent.getInitialProps = async contextData => { | ||
await Sentry.captureUnderscoreErrorException(contextData); | ||
const { 'accept-language': acceptLanguage, cookie } = | ||
contextData.req!.headers; | ||
const { language } = parseCookie(cookie), | ||
languages = parseLanguageHeader(acceptLanguage || ''); | ||
|
||
await i18n.loadLanguages([language, ...languages].filter(Boolean)); | ||
|
||
if (enableSentry) await Sentry.captureUnderscoreErrorException(contextData); | ||
|
||
return Error.getInitialProps(contextData); | ||
}; | ||
|
||
export default process.env.NODE_ENV === 'development' || | ||
!process.env.SENTRY_AUTH_TOKEN | ||
? Error | ||
: CustomErrorComponent; | ||
export default CustomErrorComponent; |
Oops, something went wrong.
57d9766
There was a problem hiding this comment.
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-6qh9t5b2f-stevending1sts-projects.vercel.app
Built with commit 57d9766.
This pull request is being automatically deployed with vercel-action