diff --git a/app.js b/app.js index e73bc69..499ef6e 100644 --- a/app.js +++ b/app.js @@ -19,12 +19,19 @@ const serve = new nodeStatic.Server(join( const server = http.createServer(); server.on('request', (request, response) => { - if (custombare.route(request, response)) return true; - - if (bareServer.shouldRoute(request)) { - bareServer.routeRequest(request, response); - } else { - serve.serve(request, response); + try { + if (custombare.route(request, response)) return true; + + if (bareServer.shouldRoute(request)) { + bareServer.routeRequest(request, response); + } else { + serve.serve(request, response); + } + } catch (e) { + response.writeHead(500, "Internal Server Error", { + "Content-Type": "text/plain" + }) + response.end(e.stack) } }); server.on('upgrade', (req, socket, head) => { diff --git a/static/customBare.mjs b/static/customBare.mjs index 91afad7..bc14db5 100644 --- a/static/customBare.mjs +++ b/static/customBare.mjs @@ -82,8 +82,8 @@ async function fetchBare(url, res, req) { request.body.pipe(res) } } catch (e) { - res.writeHead(500, 'Error', { - 'content-type': 'application/javascript' + res.writeHead(500, 'Internal Server Error', { + 'Content-Type': 'text/plain' }) res.end(e.stack); }