diff --git a/src/websrv.mjs b/src/websrv.mjs index 6dc638d..edfa3cf 100644 --- a/src/websrv.mjs +++ b/src/websrv.mjs @@ -23,6 +23,11 @@ http.createServer(async (req, res, r) => { type = "text/html", body }) => res.writeHead(code, { "Content-Type": `${type}; charset=utf-8` }).end(body); + + res.redirect = target => res.writeHead(301, { + "Cache-Control": "no-cache, public", + "Location": target + }).end(); !(r = router.routes.getRoute(req.url.pathname, req.method)) ? res.writeHead(404).end(`404 - ${req.url.pathname}`) : await r(req, res); console.log(`[${(new Date()).toLocaleTimeString()}] ${res.statusCode} ${req.method}\t${req.url.pathname}`);