change sitemap entries in robots.txt to absolute urls

This commit is contained in:
Art Lowel
2022-12-01 15:08:58 +01:00
parent e4f483c308
commit be0b54e058
5 changed files with 69 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ import * as pem from 'pem';
import * as https from 'https';
import * as morgan from 'morgan';
import * as express from 'express';
import * as ejs from 'ejs';
import * as bodyParser from 'body-parser';
import * as compression from 'compression';
@@ -120,10 +121,23 @@ export function app() {
})(_, (options as any), callback)
);
server.engine('ejs', ejs.renderFile);
/*
* Register the view engines for html and ejs
*/
server.set('view engine', 'html');
server.set('view engine', 'ejs');
/**
* Serve the robots.txt ejs template, filling in the origin variable
*/
server.get('/robots.txt', (req, res) => {
res.setHeader('content-type', 'text/plain');
res.render('assets/robots.txt.ejs', {
'origin': req.protocol + '://' + req.headers.host
});
});
/*
* Set views folder path to directory where template files are stored