-
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.
[optimize] update Upstream packages
- Loading branch information
Showing
6 changed files
with
951 additions
and
923 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,14 @@ | ||
import { FC } from 'react'; | ||
|
||
import { i18n } from '../models/Translation'; | ||
|
||
export const NotFoundCard: FC = () => | ||
i18n.currentLanguage.startsWith('zh') ? ( | ||
// @ts-ignore | ||
<script src="//cdn.dnpw.org/404/v1.min.js" jumptarget="/" jumptime="-1" /> | ||
) : ( | ||
<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'; | ||
|
||
import { NotFoundCard } from '../components/NotFoundCard'; | ||
import { i18n } from '../models/Translation'; | ||
|
||
const CustomErrorComponent: NextPage<ErrorProps> = ({ statusCode }) => ( | ||
<Error statusCode={statusCode} /> | ||
<> | ||
<h1 className="text-center">{statusCode}</h1> | ||
|
||
<NotFoundCard /> | ||
</> | ||
); | ||
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.
bf761fe
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-9o5y03vkw-stevending1sts-projects.vercel.app
Built with commit bf761fe.
This pull request is being automatically deployed with vercel-action