mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
minor changes pt.2
This commit is contained in:
parent
6275b083db
commit
76f75a2f60
17 changed files with 416 additions and 276 deletions
29
src/pages/api/validate.ts
Normal file
29
src/pages/api/validate.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const { link } = req.query as { link: string }
|
||||
let MissingParam: string | null = null
|
||||
if (!link) {
|
||||
MissingParam = 'link'
|
||||
}
|
||||
|
||||
if (MissingParam) {
|
||||
return res.status(400).json({ error: `Hiányzó paraméter: ${MissingParam}` })
|
||||
}
|
||||
|
||||
const domain = link.split('/')[2]
|
||||
if (domain !== 'dload-oktatas.educatio.hu') {
|
||||
return res.status(400).json({ error: 'Érvénytelen link' })
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(link, { method: 'HEAD' })
|
||||
const status = response.status
|
||||
res.status(200).json({ status })
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Hiányzó paraméterek:' })
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue