pdf proxy

This commit is contained in:
skidoodle 2023-12-13 10:53:22 +01:00
parent 6c591adb09
commit 15c1caf41f
4 changed files with 61 additions and 7 deletions

View file

@ -14,8 +14,11 @@ export default async function handler(
return res.status(400).json({ error: `Hiányzó paraméter: ${MissingParam}` })
}
const domain = link.split('/')[2]
if (domain !== 'dload-oktatas.educatio.hu') {
const secure = req.headers['x-forwarded-proto'] === 'https'
const protocol = secure ? 'https' : 'http'
const address = req.headers.host
if (!link.startsWith(`${protocol}://${address}`)) {
return res.status(400).json({ error: 'Érvénytelen link' })
}
@ -24,6 +27,6 @@ export default async function handler(
const status = response.status
res.status(200).json({ status })
} catch (error) {
res.status(500).json({ error: 'Hiányzó paraméterek:' })
res.status(500).json({ error: 'Internal Server Error' })
}
}