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!

πŸ› Fixes CORS proxy crash when error json has circular dependency

Alicia Sykesa4af19ffcbe5
diff --git a/services/cors-proxy.js b/services/cors-proxy.js
index afafb0a4..502f0fa7 100644
--- a/services/cors-proxy.js
+++ b/services/cors-proxy.js
@@ -37,11 +37,20 @@ module.exports = (req, res) => {
headers,
};
+ // Extract a JSON-safe summary from an axios-like error (get circular dep without this!)
+ const serializeError = (error) => ({
+ message: error.message,
+ code: error.code,
+ status: error.response && error.response.status,
+ statusText: error.response && error.response.statusText,
+ data: error.response && error.response.data,
+ });
+
// Make the request, and respond with result
request(requestConfig)
.then((response) => {
res.status(200).send(response.data);
}).catch((error) => {
- res.status(500).send({ error });
+ res.status(500).send({ error: serializeError(error) });
});
};