add robots.txt and prettier site

This commit is contained in:
Ashley 2023-02-09 16:32:14 +00:00
parent f7eff5ccd0
commit 0a8b6b3bad

View file

@ -117,9 +117,7 @@ this is our config file,you can change stuff here
app.use(function (request, response, next) { app.use(function (request, response, next) {
if (config.enablealwayshttps && !request.secure) { if (config.enablealwayshttps && !request.secure) {
return response.redirect( return response.redirect("https://" + request.headers.host + request.url);
"https://" + request.headers.host + request.url
);
} }
next(); next();
@ -127,13 +125,23 @@ this is our config file,you can change stuff here
app.use(function (req, res, next) { app.use(function (req, res, next) {
if (req.url.match(/^\/(css|js|img|font)\/.+/)) { if (req.url.match(/^\/(css|js|img|font)\/.+/)) {
res.setHeader('Cache-Control', 'public, max-age=' + config.cacher_max_age); // cache header res.setHeader(
"Cache-Control",
"public, max-age=" + config.cacher_max_age
); // cache header
res.setHeader("poketube-cacher", "STATIC_FILES"); res.setHeader("poketube-cacher", "STATIC_FILES");
} }
next(); next();
}); });
initlog("[OK] Load headers")
app.get("/robots.txt", (req, res) => {
res.sendFile(__dirname + "/robots.txt");
});
initlog("[OK] Load robots.txt")
sinit(app, config, renderTemplate); sinit(app, config, renderTemplate);
init(app); init(app);