Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ₯… Handle null headers

Alicia Sykesc07f3dc8106f
diff --git a/server.js b/server.js
index 5737245c..a043c091 100644
--- a/server.js
+++ b/server.js
@@ -146,9 +146,11 @@ const app = express()
// GET endpoint to run status of a given URL with GET request
.use(ENDPOINTS.statusCheck, (req, res) => {
try {
- statusCheck(req.url, async (results) => {
- res.setHeader('Content-Type', 'application/json');
- await res.end(results);
+ statusCheck(req.url, (results) => {
+ if (!res.headersSent) {
+ res.setHeader('Content-Type', 'application/json');
+ res.end(results);
+ }
});
} catch (e) {
printWarning(`Error running status check for ${req.url}\n`, e);
diff --git a/services/status-check.js b/services/status-check.js
index c7b76a5f..c218cf39 100644
--- a/services/status-check.js
+++ b/services/status-check.js
@@ -106,7 +106,10 @@ module.exports = (paramStr, render) => {
const maxRedirects = decodeURIComponent(params.get('maxRedirects')) || 0;
const headers = decodeHeaders(params.get('headers'));
const enableInsecure = !!params.get('enableInsecure');
- if (!url || url === 'undefined') immediateError(render);
+ if (!url || url === 'undefined') {
+ immediateError(render);
+ return;
+ }
const options = {
headers, enableInsecure, acceptCodes, maxRedirects,
};