mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
This reverts commit d4edd432d8
.
This commit is contained in:
parent
4f1cde97ec
commit
95635fca04
3 changed files with 4 additions and 38 deletions
|
@ -3,7 +3,6 @@ import { performance } from "perf_hooks";
|
|||
import { getServiceItem } from "utils/config/service-helpers";
|
||||
import createLogger from "utils/logger";
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
import {importCookieHeader} from "utils/proxy/cookie-jar";
|
||||
|
||||
const logger = createLogger("ping");
|
||||
|
||||
|
@ -26,24 +25,20 @@ export default async function handler(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
if (req.headers.cookie) {
|
||||
importCookieHeader(pingURL, req.headers.cookie)
|
||||
}
|
||||
|
||||
try {
|
||||
let startTime = performance.now();
|
||||
let [status] = await httpProxy(pingURL, {
|
||||
method: "HEAD"
|
||||
});
|
||||
let endTime = performance.now();
|
||||
|
||||
|
||||
if (status > 403) {
|
||||
// try one more time as a GET in case HEAD is rejected for whatever reason
|
||||
startTime = performance.now();
|
||||
[status] = await httpProxy(pingURL);
|
||||
endTime = performance.now();
|
||||
}
|
||||
|
||||
|
||||
return res.status(200).json({
|
||||
status,
|
||||
latency: endTime - startTime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue