mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
nagec
This commit is contained in:
parent
36a8fd8780
commit
64c6ab2041
3 changed files with 96 additions and 89 deletions
|
@ -2,6 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
import { subjects } from '@/utils/subjects'
|
import { subjects } from '@/utils/subjects'
|
||||||
|
|
||||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
try {
|
||||||
const { vizsgatargy, ev, idoszak, szint } = req.query as {
|
const { vizsgatargy, ev, idoszak, szint } = req.query as {
|
||||||
vizsgatargy: string
|
vizsgatargy: string
|
||||||
ev: string
|
ev: string
|
||||||
|
@ -87,4 +88,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
|
||||||
res.setHeader('Cache-Control', 's-maxage=31536000')
|
res.setHeader('Cache-Control', 's-maxage=31536000')
|
||||||
res.status(200).json({ flPdfUrl, utPdfUrl, flZipUrl, utZipUrl })
|
res.status(200).json({ flPdfUrl, utPdfUrl, flZipUrl, utZipUrl })
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Internal Server Error', message: error })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ export default async function handler(
|
||||||
.json({ error: 'Hiba történt a lekérés során.' })
|
.json({ error: 'Hiba történt a lekérés során.' })
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
res.status(500).json({ error: 'Internal Server Error', message: error })
|
||||||
res.status(500).json({ error: 'Internal Server Error' })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,11 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
const domain = link.split('/')[2]
|
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' })
|
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' })
|
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) {
|
if (!response.ok) {
|
||||||
return res
|
return res
|
||||||
|
@ -37,6 +41,6 @@ export default async function handler(
|
||||||
const status = response.status
|
const status = response.status
|
||||||
res.status(200).json({ status })
|
res.status(200).json({ status })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: 'Internal Server Error' })
|
res.status(500).json({ error: 'Internal Server Error', message: error })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue