mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-13 08:55:48 +01:00
🐛 Fix a small bug with the ping system
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import axios from 'axios';
|
import axios, { AxiosError } from 'axios';
|
||||||
import https from 'https';
|
import https from 'https';
|
||||||
import Consola from 'consola';
|
import Consola from 'consola';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
@@ -12,14 +12,15 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
res.status(response.status).json(response.statusText);
|
res.status(response.status).json(response.statusText);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error: AxiosError) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
Consola.error(`Unexpected response: ${error.response.data}`);
|
Consola.warn(`Unexpected response: ${error.message}`);
|
||||||
res.status(error.response.status).json(error.response.statusText);
|
res.status(error.response.status).json(error.response.statusText);
|
||||||
} else if (error.code === 'ECONNABORTED') {
|
} else if (error.code === 'ECONNABORTED') {
|
||||||
res.status(408).json('Request Timeout');
|
res.status(408).json('Request Timeout');
|
||||||
} else {
|
} else {
|
||||||
res.status(error.response ? error.response.status : 500).json('Server Error');
|
Consola.error(`Unexpected error: ${error.message}`);
|
||||||
|
res.status(500).json('Internal Server Error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// // Make a request to the URL
|
// // Make a request to the URL
|
||||||
|
|||||||
Reference in New Issue
Block a user