diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx new file mode 100644 index 0000000..bb273f5 --- /dev/null +++ b/src/pages/_error.tsx @@ -0,0 +1,60 @@ +import { Footer } from '@/components/Footer' +import { Button } from '@nextui-org/button' +import Link from 'next/link' +import type { GetServerSideProps, GetServerSidePropsContext } from 'next' + +interface ErrorProps { + statusCode: number +} + +const ErrorPage: React.FC = ({ statusCode }) => { + return ( + <> +
+

+ {statusCode} +

+
+
+
+
+
+ {statusCode == 404 ? ( + <> +

Az keresett oldal nem található.

+

+ +

+ + ) : ( + <> +

Váratlan hiba történt.

+

+ +

+ + )} +
+
+
+
+
+
+
+ + ) +} + +export const getServerSideProps: GetServerSideProps = async ( + context: GetServerSidePropsContext +) => ({ + props: { + statusCode: context.res ? context.res.statusCode : 404, + }, +}) + +export default ErrorPage diff --git a/src/pages/api/proxy.ts b/src/pages/api/proxy.ts index d75e6c7..16921db 100644 --- a/src/pages/api/proxy.ts +++ b/src/pages/api/proxy.ts @@ -23,11 +23,11 @@ export default async function handler( res.setHeader('Cache-Control', 's-maxage=31536000') const response = await fetch(link, { method: 'GET' }) const contentType = response.headers.get('content-type') + if (contentType == 'application/pdf') { + const filename = link.split('/').pop() ?? 'document.pdf' res.setHeader('Content-Type', contentType) - } else { - const filename = link.split('/').pop() ?? 'download' - res.setHeader('Content-Disposition', `attachment; filename="${filename}"`) + res.setHeader('Content-Disposition', `inline; filename="${filename}"`) } if (response.ok) { diff --git a/src/pages/api/validate.ts b/src/pages/api/validate.ts index 0b7faec..4013856 100644 --- a/src/pages/api/validate.ts +++ b/src/pages/api/validate.ts @@ -5,13 +5,13 @@ export default async function handler( res: NextApiResponse ) { const { link } = req.query as { link: string } - let MissingParam: string | null = null + let missingParam: string | null = null if (!link) { - MissingParam = 'link' + missingParam = 'link' } - if (MissingParam) { - return res.status(400).json({ error: `Hiányzó paraméter: ${MissingParam}` }) + if (missingParam) { + return res.status(400).json({ error: `Hiányzó paraméter: ${missingParam}` }) } try {