This commit is contained in:
skidoodle 2024-01-25 12:11:17 +01:00
parent 36a8fd8780
commit 64c6ab2041
3 changed files with 96 additions and 89 deletions

View file

@ -2,6 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'
import { subjects } from '@/utils/subjects'
export default function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { vizsgatargy, ev, idoszak, szint } = req.query as {
vizsgatargy: string
ev: string
@ -87,4 +88,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
res.setHeader('Cache-Control', 's-maxage=31536000')
res.status(200).json({ flPdfUrl, utPdfUrl, flZipUrl, utZipUrl })
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', message: error })
}
}

View file

@ -40,7 +40,6 @@ export default async function handler(
.json({ error: 'Hiba történt a lekérés során.' })
}
} catch (error) {
console.error(error)
res.status(500).json({ error: 'Internal Server Error' })
res.status(500).json({ error: 'Internal Server Error', message: error })
}
}

View file

@ -16,7 +16,11 @@ export default async function handler(
}
const domain = link.split('/')[2]
if (domain !== 'localhost:3000' && domain !== 'erettsegi.albert.lol') {
if (
domain !== 'localhost:3000' &&
domain !== 'erettsegi.albert.lol' &&
domain !== 'dload-oktatas.educatio.hu'
) {
return res.status(400).json({ error: 'Érvénytelen link' })
}
@ -26,7 +30,7 @@ export default async function handler(
return res.status(400).json({ error: 'Érvénytelen link' })
}
const response = await fetch(link, { method: 'OPTIONS' })
const response = await fetch(link, { method: 'HEAD' })
if (!response.ok) {
return res
@ -37,6 +41,6 @@ export default async function handler(
const status = response.status
res.status(200).json({ status })
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' })
res.status(500).json({ error: 'Internal Server Error', message: error })
}
}