mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
fix
This commit is contained in:
parent
3e8dfabcc4
commit
50df2a4739
3 changed files with 67 additions and 7 deletions
60
src/pages/_error.tsx
Normal file
60
src/pages/_error.tsx
Normal file
|
@ -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<ErrorProps> = ({ statusCode }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<main className='dark:bg-[#121212] text-foreground bg-background py-5'>
|
||||||
|
<h1 className='text-7xl font-bold text-blue-400 text-center mt-16'>
|
||||||
|
{statusCode}
|
||||||
|
</h1>
|
||||||
|
<div className='flex min-h-screen flex-col items-center justify-between'>
|
||||||
|
<div className='container mx-auto'>
|
||||||
|
<div className='flex flex-col items-center justify-center'>
|
||||||
|
<div className='mt-5 mb-3'>
|
||||||
|
<div className='text-2xl font-semibold text-gray-600'>
|
||||||
|
{statusCode == 404 ? (
|
||||||
|
<>
|
||||||
|
<p className='mt-2'>Az keresett oldal nem található.</p>
|
||||||
|
<p className='mt-8 text-center'>
|
||||||
|
<Button color='primary'>
|
||||||
|
<Link href='/'>{'Vissza'}</Link>
|
||||||
|
</Button>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<p className='mt-2'>Váratlan hiba történt.</p>
|
||||||
|
<p className='mt-8 text-center'>
|
||||||
|
<Button color='primary'>
|
||||||
|
<Link href='/'>{'Vissza'}</Link>
|
||||||
|
</Button>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getServerSideProps: GetServerSideProps<ErrorProps> = async (
|
||||||
|
context: GetServerSidePropsContext
|
||||||
|
) => ({
|
||||||
|
props: {
|
||||||
|
statusCode: context.res ? context.res.statusCode : 404,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default ErrorPage
|
|
@ -23,11 +23,11 @@ export default async function handler(
|
||||||
res.setHeader('Cache-Control', 's-maxage=31536000')
|
res.setHeader('Cache-Control', 's-maxage=31536000')
|
||||||
const response = await fetch(link, { method: 'GET' })
|
const response = await fetch(link, { method: 'GET' })
|
||||||
const contentType = response.headers.get('content-type')
|
const contentType = response.headers.get('content-type')
|
||||||
|
|
||||||
if (contentType == 'application/pdf') {
|
if (contentType == 'application/pdf') {
|
||||||
|
const filename = link.split('/').pop() ?? 'document.pdf'
|
||||||
res.setHeader('Content-Type', contentType)
|
res.setHeader('Content-Type', contentType)
|
||||||
} else {
|
res.setHeader('Content-Disposition', `inline; filename="${filename}"`)
|
||||||
const filename = link.split('/').pop() ?? 'download'
|
|
||||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
|
|
@ -5,13 +5,13 @@ export default async function handler(
|
||||||
res: NextApiResponse
|
res: NextApiResponse
|
||||||
) {
|
) {
|
||||||
const { link } = req.query as { link: string }
|
const { link } = req.query as { link: string }
|
||||||
let MissingParam: string | null = null
|
let missingParam: string | null = null
|
||||||
if (!link) {
|
if (!link) {
|
||||||
MissingParam = 'link'
|
missingParam = 'link'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MissingParam) {
|
if (missingParam) {
|
||||||
return res.status(400).json({ error: `Hiányzó paraméter: ${MissingParam}` })
|
return res.status(400).json({ error: `Hiányzó paraméter: ${missingParam}` })
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue