Merge pull request #511 from singular0/no-ssl-cert-validation

Allow self-signed certificates for ping
This commit is contained in:
Thomas Camlong
2022-11-22 11:05:23 +09:00
committed by GitHub

View File

@@ -1,11 +1,13 @@
import axios from 'axios';
import https from 'https';
import { NextApiRequest, NextApiResponse } from 'next';
async function Get(req: NextApiRequest, res: NextApiResponse) {
// Parse req.body as a ServiceItem
const { url } = req.query;
const agent = new https.Agent({ rejectUnauthorized: false });
await axios
.get(url as string)
.get(url as string, { httpsAgent: agent })
.then((response) => {
res.status(response.status).json(response.statusText);
})